W3C home > Mailing lists > Public > www-validator-cvs@w3.org > August 2007

2002/css-validator/org/w3c/css/servlet CssValidator.java,1.35,1.36

From: Julien Grand-Mourcel via cvs-syncmail <cvsmail@w3.org>
Date: Fri, 10 Aug 2007 15:17:34 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1IJWF4-0007GZ-Iz@lionel-hutz.w3.org>

Update of /sources/public/2002/css-validator/org/w3c/css/servlet
In directory hutz:/tmp/cvs-serv27854/org/w3c/css/servlet

Modified Files:
	CssValidator.java 
Log Message:
Changing the inCSS() method so that it doesn't do an infinite loop (for no reason)

Index: CssValidator.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/servlet/CssValidator.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- CssValidator.java	10 Aug 2007 14:52:36 -0000	1.35
+++ CssValidator.java	10 Aug 2007 15:17:31 -0000	1.36
@@ -408,8 +408,15 @@
      * @return <tt>false</tt> if it contains the style tag well formed 
      */
     private boolean isCSS(String text) {
-		String anyChar = "(.|\n|\r)*";
-		return !text.toLowerCase().matches(anyChar + "<style"+anyChar+">"+anyChar+"</style>"+anyChar);
+		try {
+			text = text.toLowerCase();
+			int p = text.indexOf("<style");
+			return p == -1 || p > text.indexOf("</style>");
+		} catch (Exception e) {
+			System.err.println("error: " + e.getMessage());
+			return true;
+		}
+		
 	}
 
 	/**
@@ -635,6 +642,7 @@
 		//if CSS:
 		
 		if (isCSS) {
+			System.err.println("css");
 			parser = new StyleSheetParser();
 	  	    parser.parseStyleElement(ac, is, null, usermedium,
 	  			new URL(fileName), 0);
@@ -642,6 +650,7 @@
 	  	    handleRequest(ac, res, fileName, parser
 	  			  .getStyleSheet(), output, warningLevel, errorReport);
 		} else {
+			System.err.println("html");
 			// try HTML
 			TagSoupStyleSheetHandler handler = new TagSoupStyleSheetHandler(null, ac);
 			handler.parse(is, fileName);
@@ -651,7 +660,7 @@
 		}
 	} catch (ProtocolException pex) {
 		if (Util.onDebug) {
-		    pex.printStackTrace();
+		    //pex.printStackTrace();
 		}
 		res.setHeader("WWW-Authenticate", pex.getMessage());
 		res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
Received on Friday, 10 August 2007 15:17:41 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:02:24 UTC