Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/org/adblockplus/sbrowser/contentblocker/engine/Subscription.java

Issue 29372653: Issue 4813 - UTFDataFormatException while serializing filter (Closed)
Patch Set: Removing Java 7 StandardCharsets for now Created Jan. 30, 2017, 9:13 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/org/adblockplus/sbrowser/contentblocker/engine/Subscription.java
===================================================================
--- a/src/org/adblockplus/sbrowser/contentblocker/engine/Subscription.java
+++ b/src/org/adblockplus/sbrowser/contentblocker/engine/Subscription.java
@@ -431,17 +431,19 @@ final class Subscription
filtersOut.writeInt(0);
}
else
{
filtersOut.writeInt(this.filters.size());
filtersOut.writeUTF(createFilterHash(new ArrayList<String>(this.filters)));
for (final String s : this.filters)
{
- filtersOut.writeUTF(s);
+ final byte[] b = s.getBytes("UTF-8");
anton 2017/02/16 06:17:24 wouldn't it be better to have static final String
diegocarloslima 2017/02/22 22:43:53 Acknowledged.
+ filtersOut.writeInt(b.length);
+ filtersOut.write(b);
}
}
}
finally
{
filtersOut.close();
}
}
@@ -488,17 +490,20 @@ final class Subscription
this.filters = null;
}
else
{
this.filters = new HashSet<String>();
final String filtersHash = in.readUTF();
for (int i = 0; i < numFilters; i++)
{
- this.filters.add(in.readUTF());
+ final int length = in.readInt();
+ final byte[] b = new byte[length];
+ in.readFully(b);
+ this.filters.add(new String(b, "UTF-8"));
}
this.filtersValid = createFilterHash(new ArrayList<String>(this.filters)).equals(
filtersHash);
Log.d(TAG, "Filters valid: " + this.filtersValid);
}
}
finally
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld