Skip to content

Commit

Permalink
CSS: attribute selectors: fix parsing of case insensitive flag
Browse files Browse the repository at this point in the history
The ' i' flag should be outside the parenthesis with the attribute
value:
div[foo="bar i"] should not match foo="bar" nor foo="BAR", but
only foo="bar i".

Also, "div[foo=], blockquote {...}" is invalid and should make
the whole declaration discarded (including the blockquote).
  • Loading branch information
poire-z committed Aug 3, 2019
1 parent 6628aa1 commit 5e940f1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crengine/src/lvstsheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2871,16 +2871,18 @@ bool parse_attr_value( const char * &str, char * buf, bool &parse_trailing_i, ch
buf[pos] = 0;
str += pos+1;
skip_spaces( str );
if (*str != stop_char)
return false;
str++;
if (parse_trailing_i && pos >=2) {
// The trailing ' i' must be outside the quotes
if (parse_trailing_i) {
parse_trailing_i = false;
if ( (buf[pos-2]==' ') && (buf[pos-1]=='i' || buf[pos-1]=='I') ) {
if (*str == 'i' || *str == 'I') {
parse_trailing_i = true;
buf[pos-2] = 0;
str++;
skip_spaces( str );
}
}
if (*str != stop_char)
return false;
str++;
return true;
}
else
Expand All @@ -2893,6 +2895,8 @@ bool parse_attr_value( const char * &str, char * buf, bool &parse_trailing_i, ch
int end_pos = pos;
if (parse_trailing_i) {
parse_trailing_i = false;
if (end_pos == 0) // Empty value, or some leading space: this is invalid
return false;
if (str[pos] && str[pos]==' ' && str[pos+1] && (str[pos+1]=='i' || str[pos+1]=='I')) {
parse_trailing_i = true;
pos+=2;
Expand Down

0 comments on commit 5e940f1

Please sign in to comment.