Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 if (this.filters == null) | 429 if (this.filters == null) |
430 { | 430 { |
431 filtersOut.writeInt(0); | 431 filtersOut.writeInt(0); |
432 } | 432 } |
433 else | 433 else |
434 { | 434 { |
435 filtersOut.writeInt(this.filters.size()); | 435 filtersOut.writeInt(this.filters.size()); |
436 filtersOut.writeUTF(createFilterHash(new ArrayList<String>(this.filters) )); | 436 filtersOut.writeUTF(createFilterHash(new ArrayList<String>(this.filters) )); |
437 for (final String s : this.filters) | 437 for (final String s : this.filters) |
438 { | 438 { |
439 filtersOut.writeUTF(s); | 439 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.
| |
440 filtersOut.writeInt(b.length); | |
441 filtersOut.write(b); | |
440 } | 442 } |
441 } | 443 } |
442 } | 444 } |
443 finally | 445 finally |
444 { | 446 { |
445 filtersOut.close(); | 447 filtersOut.close(); |
446 } | 448 } |
447 } | 449 } |
448 | 450 |
449 public void serializeSubscription(final File metaFile, final File filtersFile) throws IOException | 451 public void serializeSubscription(final File metaFile, final File filtersFile) throws IOException |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 if (numFilters == 0) | 488 if (numFilters == 0) |
487 { | 489 { |
488 this.filters = null; | 490 this.filters = null; |
489 } | 491 } |
490 else | 492 else |
491 { | 493 { |
492 this.filters = new HashSet<String>(); | 494 this.filters = new HashSet<String>(); |
493 final String filtersHash = in.readUTF(); | 495 final String filtersHash = in.readUTF(); |
494 for (int i = 0; i < numFilters; i++) | 496 for (int i = 0; i < numFilters; i++) |
495 { | 497 { |
496 this.filters.add(in.readUTF()); | 498 final int length = in.readInt(); |
499 final byte[] b = new byte[length]; | |
500 in.readFully(b); | |
501 this.filters.add(new String(b, "UTF-8")); | |
497 } | 502 } |
498 this.filtersValid = createFilterHash(new ArrayList<String>(this.filters) ).equals( | 503 this.filtersValid = createFilterHash(new ArrayList<String>(this.filters) ).equals( |
499 filtersHash); | 504 filtersHash); |
500 Log.d(TAG, "Filters valid: " + this.filtersValid); | 505 Log.d(TAG, "Filters valid: " + this.filtersValid); |
501 } | 506 } |
502 } | 507 } |
503 finally | 508 finally |
504 { | 509 { |
505 in.close(); | 510 in.close(); |
506 } | 511 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 this.serializeMetaData(metaFile); | 635 this.serializeMetaData(metaFile); |
631 if (filtersChanged) | 636 if (filtersChanged) |
632 { | 637 { |
633 this.serializeFilters(filtersFile); | 638 this.serializeFilters(filtersFile); |
634 this.clearFilters(); | 639 this.clearFilters(); |
635 } | 640 } |
636 | 641 |
637 return filtersChanged; | 642 return filtersChanged; |
638 } | 643 } |
639 } | 644 } |
OLD | NEW |