W3C home > Mailing lists > Public > www-validator-cvs@w3.org > March 2008

2002/css-validator/org/w3c/css/parser/analyzer CssParser.java,1.42,1.43

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Fri, 28 Mar 2008 15:39:30 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1JfGfy-0006dm-D5@lionel-hutz.w3.org>

Update of /sources/public/2002/css-validator/org/w3c/css/parser/analyzer
In directory hutz:/tmp/cvs-serv25370

Modified Files:
	CssParser.java 
Log Message:
see CssParser.jj

Index: CssParser.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParser.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- CssParser.java	28 Mar 2008 15:12:07 -0000	1.42
+++ CssParser.java	28 Mar 2008 15:39:28 -0000	1.43
@@ -2012,7 +2012,7 @@
       /*  "." n=<IDENT> { */
           n = jj_consume_token(CLASS);
         try {
-            s.addClass(new ClassSelector(convertIdent(n.image.substring(1))));
+            s.addClass(new ClassSelector(convertClassIdent(n.image.substring(1))));
             //        s.addAttribute("class", convertIdent(n.image.substring(1)),
             //           CssSelectors.ATTRIBUTE_CLASS_SEL);
         } catch (InvalidParamException e) {
@@ -2237,7 +2237,7 @@
         break;
       case STRING:
         val = jj_consume_token(STRING);
-                 val.image = convertStringIndex(val.image, 1, val.image.length() -1);
+                 val.image = convertStringIndex(val.image, 1, val.image.length() -1, false);
         label_63:
         while (true) {
           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -2384,7 +2384,7 @@
           }
                 try {
                     s.setPseudoFun(convertStringIndex(n.image, 0,
-                                            n.image.length() -1).toLowerCase(),
+                                                      n.image.length() -1, false).toLowerCase(),
                                    convertIdent(language.image));
                 } catch(InvalidParamException e) {
                         removeThisRule();
@@ -2408,7 +2408,7 @@
           param = simple_selector(null);
                 try {
                     s.setPseudoFun(convertStringIndex(n.image, 0,
-                                            n.image.length() -1).toLowerCase(),
+                                                      n.image.length() -1, false).toLowerCase(),
                                    param.toString());
                 } catch(InvalidParamException e) {
                     removeThisRule();
@@ -3078,7 +3078,7 @@
     addError(e, s.toString());
   }
 
-  String convertStringIndex(String s, int start, int len) throws ParseException {
+  String convertStringIndex(String s, int start, int len, boolean escapeFirst) throws ParseException {
     StringBuilder buf = new StringBuilder(len);
     int index = start;
     int t;
@@ -3123,12 +3123,14 @@
                             break;
                         }
                     }
-                    if (numValue < 255 && numValue>31) {
+                    if (!escapeFirst && numValue < 255 && numValue>31) {
                         if (! ( (numValue>96 && numValue<123) // [a-z]
                                 || (numValue>64 && numValue<91) // [A-Z]
                                 || (numValue>47 && numValue<58) // [0-9]
                                 || (numValue == 95) // _
-                                || (numValue == 45) )) { // -
+                                || (numValue == 45) // -
+                                )
+                            ) {
                             buf.append('\\');
                         }
                         buf.append((char) numValue);
@@ -3174,17 +3176,22 @@
         } else {
             buf.append(c);
         }
+        escapeFirst = false;
         index++;
     }
     return buf.toString();
   }
 
   String convertIdent(String s) throws ParseException {
-    return convertStringIndex(s, 0, s.length());
+    return convertStringIndex(s, 0, s.length(), false);
+  }
+
+  String convertClassIdent(String s) throws ParseException {
+    return convertStringIndex(s, 0, s.length(), true);
   }
 
   String convertString(String s) throws ParseException {
-    return convertStringIndex(s, 0, s.length());
+    return convertStringIndex(s, 0, s.length(), false);
   }
 
   public CssParserTokenManager token_source;
Received on Friday, 28 March 2008 15:40:05 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:00 GMT