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

Unified Diff: compiled/filter/CommentFilter.cpp

Issue 29606600: Issue 5146 - Implement DownloadableSubscription parsing in C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Nov. 13, 2017, 10:25 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
Index: compiled/filter/CommentFilter.cpp
===================================================================
--- a/compiled/filter/CommentFilter.cpp
+++ b/compiled/filter/CommentFilter.cpp
@@ -15,16 +15,59 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CommentFilter.h"
CommentFilter::CommentFilter(const String& text)
: Filter(classType, text)
{
+ if (text[0] == u'!') // this is unlikely to be false at that point
+ {
+ bool foundColon = false;
hub 2017/11/13 22:35:27 this is currently untested. And I'm not sure it be
+ String::size_type beginParam = 0;
+ String::size_type endParam = 0;
+ String::size_type beginValue = 0;
+ for (String::size_type i = 1; i < mText.length(); i++)
+ {
+ switch (mText[i])
+ {
+ case ' ':
+ case '\t':
+ if (beginParam > 0 && !foundColon)
+ {
+ endParam = i - 1;
+ }
+ break;
+ case ':':
+ foundColon = true;
+ break;
+ default:
+ if (foundColon)
+ {
+ beginValue = i;
+ }
+ else
+ {
+ if (beginParam == 0)
+ beginParam = i;
+ }
+ break;
+ }
+ if (beginValue > 0)
+ break;
+ }
+ if (beginValue > 0)
+ {
+ mParam = DependentString(mText, beginParam, endParam - beginParam);
+ mParam.toLower();
+ mValue = DependentString(mText, beginValue,
+ mText.length() - 1 - beginValue);
+ }
+ }
}
Filter::Type CommentFilter::Parse(const String& text)
{
if (text.length() && text[0] == u'!')
return Type::COMMENT;
else
return Type::UNKNOWN;

Powered by Google App Engine
This is Rietveld