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

Side by Side Diff: compiled/filter/RegExpFilter.cpp

Issue 29581602: Issue 5141 - [emscripten] Convert filter matcher to C++ Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created Oct. 17, 2017, 12:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 303 }
304 304
305 data.mPatternEnd = text.find(u'$', data.mPatternStart); 305 data.mPatternEnd = text.find(u'$', data.mPatternStart);
306 if (data.mPatternEnd == text.npos) 306 if (data.mPatternEnd == text.npos)
307 data.mPatternEnd = text.length(); 307 data.mPatternEnd = text.length();
308 308
309 ParseOptions(text, error, data, data.mPatternEnd + 1); 309 ParseOptions(text, error, data, data.mPatternEnd + 1);
310 if (!error.empty()) 310 if (!error.empty())
311 return Type::INVALID; 311 return Type::INVALID;
312 312
313 data.mRegexpId = -1;
313 if (data.mPatternEnd - data.mPatternStart >= 2 && 314 if (data.mPatternEnd - data.mPatternStart >= 2 &&
314 text[data.mPatternStart] == u'/' && 315 text[data.mPatternStart] == u'/' &&
315 text[data.mPatternEnd - 1] == u'/') 316 text[data.mPatternEnd - 1] == u'/')
316 { 317 {
317 data.SetRegExp(GenerateRegExp(DependentString(text, data.mPatternStart + 1, 318 data.mRegexpId = GenerateRegExp(DependentString(text,
318 data.mPatternEnd - data.mPatternStart - 2), data.mMatchCase)); 319 data.mPatternStart + 1, data.mPatternEnd - data.mPatternStart - 2),
320 data.mMatchCase);
319 if (data.mRegexpId == -1) 321 if (data.mRegexpId == -1)
320 { 322 {
321 error.reset(u"filter_invalid_regexp"_str); 323 error.reset(u"filter_invalid_regexp"_str);
322 return Type::INVALID; 324 return Type::INVALID;
323 } 325 }
324 } 326 }
325 327
326 return type; 328 return type;
327 } 329 }
328 330
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 if (!(mData.mContentType & typeMask) || 385 if (!(mData.mContentType & typeMask) ||
384 (mData.mThirdParty == TrippleState::YES && !thirdParty) || 386 (mData.mThirdParty == TrippleState::YES && !thirdParty) ||
385 (mData.mThirdParty == TrippleState::NO && thirdParty) || 387 (mData.mThirdParty == TrippleState::NO && thirdParty) ||
386 !IsActiveOnDomain(docDomain, sitekey)) 388 !IsActiveOnDomain(docDomain, sitekey))
387 { 389 {
388 return false; 390 return false;
389 } 391 }
390 392
391 if (!mData.RegExpParsingDone()) 393 if (!mData.RegExpParsingDone())
392 { 394 {
393 const OwnedString pattern(mData.GetRegExpSource(mText)); 395 const OwnedString pattern(mData.GetRegExpSource(mText));
sergei 2017/10/18 10:58:42 BTW, `pattern` should be a DependentString there i
394 mData.SetRegExp(GenerateRegExp(RegExpFromSource(pattern), mData.mMatchCase)) ; 396 mData.mRegexpId = GenerateRegExp(RegExpFromSource(pattern), mData.mMatchCase );
395 } 397 }
396 return TestRegExp(mData.mRegexpId, location); 398 return TestRegExp(mData.mRegexpId, location);
397 } 399 }
OLDNEW

Powered by Google App Engine
This is Rietveld