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

2002/css-validator/org/w3c/css/parser/analyzer CssParser.jj,1.40,1.41

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

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

Modified Files:
	CssParser.jj 
Log Message:
.\35 5ft now giver .\0000355ft instead of the invalid .55ft


Index: CssParser.jj
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/analyzer/CssParser.jj,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- CssParser.jj	28 Mar 2008 15:11:55 -0000	1.40
+++ CssParser.jj	28 Mar 2008 15:39:12 -0000	1.41
@@ -1375,7 +1375,7 @@
     /*  "." n=<IDENT> { */
     n=<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) {
@@ -1499,7 +1499,7 @@
 	 ( val=<IDENT> 
 	     { val.image = convertIdent(val.image); }
 	   | ( val=<STRING> 
-	       { val.image = convertStringIndex(val.image, 1, val.image.length() -1);} 
+	       { val.image = convertStringIndex(val.image, 1, val.image.length() -1, false);} 
 			   ) 
 	   ( <S> )* ) )?
   <RBRACKET>
@@ -1595,7 +1595,7 @@
 	| ( ( n=<FUNCTIONLANG> ( <S> )* (language=<NUMBER> | language=<IDENT> | language=<STRING> ) ) {
 		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();
@@ -1605,7 +1605,7 @@
 	    | ( n=<FUNCTION> ( <S> )* 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();
@@ -2060,9 +2060,8 @@
     addError(e, s.toString()); 
 }
 
-
 JAVACODE
-String convertStringIndex(String s, int start, int len) {
+String convertStringIndex(String s, int start, int len, boolean escapeFirst) {
     StringBuilder buf = new StringBuilder(len);
     int index = start;
     int t;
@@ -2107,12 +2106,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);
@@ -2158,6 +2159,7 @@
 	} else {
 	    buf.append(c);
 	}
+	escapeFirst = false;
 	index++;
     }
     return buf.toString();
@@ -2165,12 +2167,17 @@
 
 JAVACODE
 String convertIdent(String s) {
-    return convertStringIndex(s, 0, s.length());
+    return convertStringIndex(s, 0, s.length(), false);
+}
+
+JAVACODE
+String convertClassIdent(String s) {
+    return convertStringIndex(s, 0, s.length(), true);
 }
 
 JAVACODE
 String convertString(String s) {
-    return convertStringIndex(s, 0, s.length());
+    return convertStringIndex(s, 0, s.length(), false);
 }
 
 /*
Received on Friday, 28 March 2008 15:39:51 GMT

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