| 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; |