File tree Expand file tree Collapse file tree
main/java/ch/digitalfondue/jfiveparse
test/java/ch/digitalfondue/jfiveparse Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ record Combinator(int type) implements CssSelector {}
6565 record TagSelector (String name , String namespace ) implements CssSelector {}
6666
6767
68-
68+ static final int IGNORE_CASE_UNKNOWN = - 1 ;
6969 static final int IGNORE_CASE_TRUE = 0 ;
7070 static final int IGNORE_CASE_FALSE = 1 ;
7171 static final int IGNORE_CASE_QUIRKS = 2 ;
@@ -338,6 +338,12 @@ int parse() {
338338 name = getName (1 );
339339 }
340340 }
341+
342+ // Support unescaped colons in attribute names (e.g., xml:lang)
343+ while (selector .charAt (selectorIndex ) == ':' ) {
344+ name = name + ":" + getName (1 );
345+ }
346+
341347 stripWhitespace (0 );
342348 // Determine comparison operation
343349 int action = ATTR_ACTION_EXISTS ;
@@ -355,7 +361,7 @@ int parse() {
355361 }
356362
357363 String value = "" ;
358- int ignoreCase = - 1 ;
364+ int ignoreCase = IGNORE_CASE_UNKNOWN ;
359365
360366 if (action != ATTR_ACTION_EXISTS ) {
361367 if (isQuote (charAt (selectorIndex ))) {
Original file line number Diff line number Diff line change @@ -205,6 +205,21 @@ void checkEscapedWhitespace() {
205205 )), r );
206206 }
207207
208+ @ Test
209+ void checkUnescapedColon () {
210+ var r = CSS .parseSelector ("*[xml:lang|=\" es\" ]" );
211+ assertEquals (List .of (List .of (
212+ new CSS .UniversalSelector (null ),
213+ new CSS .AttributeSelector (
214+ "xml:lang" ,
215+ CSS .ATTR_ACTION_HYPHEN ,
216+ "es" ,
217+ CSS .IGNORE_CASE_UNKNOWN ,
218+ null
219+ )
220+ )), r );
221+ }
222+
208223 // TODO: add all the missing String.raw tests
209224
210225 record NthExprAB (String expr , int a , int b ) {}
You can’t perform that action at this time.
0 commit comments