Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Commit

Permalink
Merge pull request #196 from brave/compatible-tags
Browse files Browse the repository at this point in the history
Make ad-block tag serialization compatible with old version
  • Loading branch information
bbondy committed Mar 14, 2019
2 parents 78cc836 + 098021b commit 74b167c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ad_block_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1507,11 +1507,12 @@ int serializeFilters(char * buffer, size_t bufferSizeAvail,

if (f->tagLen > 0) {
if (buffer) {
buffer[bufferSize] = '#';
memcpy(buffer + bufferSize + 1, f->tag, f->tagLen);
buffer[bufferSize + 1 + f->tagLen] = ',';
buffer[bufferSize] = '~';
buffer[bufferSize + 1] = '#';
memcpy(buffer + bufferSize + 2, f->tag, f->tagLen);
buffer[bufferSize + 2 + f->tagLen] = ',';
}
bufferSize += f->tagLen + 2;
bufferSize += f->tagLen + 3;
}

if (f->domainList) {
Expand Down Expand Up @@ -1740,8 +1741,8 @@ int deserializeFilters(char *buffer, Filter *f, int numFilters) {

// If the domain section starts with a # then we're in a tag
// block.
if (buffer[pos] == '#') {
pos++;
if (buffer[pos] == '~' && buffer[pos + 1] == '#') {
pos+=2;
f->tag = buffer + pos;
f->tagLen = 0;
while (buffer[pos + f->tagLen] != '\0') {
Expand Down

0 comments on commit 74b167c

Please sign in to comment.