| 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 |
| @@ -23,16 +23,17 @@ import java.io.BufferedReader; |
| import java.io.DataInputStream; |
| import java.io.DataOutputStream; |
| import java.io.File; |
| import java.io.FileInputStream; |
| import java.io.FileOutputStream; |
| import java.io.IOException; |
| import java.io.StringReader; |
| import java.net.URL; |
| +import java.nio.charset.StandardCharsets; |
| import java.security.MessageDigest; |
| import java.security.NoSuchAlgorithmException; |
| import java.util.ArrayList; |
| import java.util.Collection; |
| import java.util.Collections; |
| import java.util.HashMap; |
| import java.util.HashSet; |
| import java.util.List; |
| @@ -431,17 +432,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(StandardCharsets.UTF_8); |
|
anton
2017/01/23 06:49:40
StandardCharsets is available starting Java 7. If
diegocarloslima
2017/01/30 17:14:30
For instance, I'll use Charset.forName("UTF-8"). T
|
| + filtersOut.writeInt(b.length); |
| + filtersOut.write(b); |
| } |
| } |
| } |
| finally |
| { |
| filtersOut.close(); |
| } |
| } |
| @@ -488,17 +491,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, StandardCharsets.UTF_8)); |
| } |
| this.filtersValid = createFilterHash(new ArrayList<String>(this.filters)).equals( |
| filtersHash); |
| Log.d(TAG, "Filters valid: " + this.filtersValid); |
| } |
| } |
| finally |
| { |