class selector matching bug

David Hyatt hyatt at apple.com
Sat Oct 18 14:51:23 CEST 2003


Test page that shows the problem here:

http://dotclue.org/safari/css2.html

Patch:

-------------- next part --------------
Index: khtml/css/cssstyleselector.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/cssstyleselector.cpp,v
retrieving revision 1.98
diff -u -p -r1.98 khtml/css/cssstyleselector.cpp
--- khtml/css/cssstyleselector.cpp	2003/10/17 22:32:13	1.98
+++ khtml/css/cssstyleselector.cpp	2003/10/18 20:43:31
@@ -843,11 +843,20 @@ bool CSSStyleSelector::checkOneSelector(
             
             QString str = value.string();
             QString selStr = sel->value.string();
-            int pos = str.find(selStr, 0, isXMLDoc);
-            if(pos == -1) return false;
-            if(pos && str[pos-1] != ' ') return false;
-            pos += selStr.length();
-            if(pos < (int)str.length() && str[pos] != ' ') return false;
+            int startSearchAt = 0;
+            while (true) {
+                int foundPos = str.find(selStr, startSearchAt, isXMLDoc);
+                if (foundPos == -1) return false;
+                if (foundPos == 0 || str[foundPos-1] == ' ') {
+                    uint endStr = foundPos + selStr.length();
+                    if (endStr == str.length() || str[endStr] == ' ')
+                        break; // We found a match.
+                }
+                
+                // No match.  Keep looking.
+                startSearchAt = foundPos + 1;
+            }
+
             break;
         }
         case CSSSelector::Contain:
-------------- next part --------------


dave


More information about the Khtml-devel mailing list