Author: toad
Date: 2006-09-01 20:41:57 +0000 (Fri, 01 Sep 2006)
New Revision: 10331

Modified:
   trunk/freenet/src/freenet/clients/http/filter/CSSTokenizerFilter.java
   trunk/freenet/src/freenet/clients/http/filter/CSSTokenizerFilter.jflex
   trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java
Log:
Fix #709 (CSS multi-line comments; actually it was a bug in the HTML parser...)

Modified: trunk/freenet/src/freenet/clients/http/filter/CSSTokenizerFilter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/CSSTokenizerFilter.java       
2006-09-01 20:32:42 UTC (rev 10330)
+++ trunk/freenet/src/freenet/clients/http/filter/CSSTokenizerFilter.java       
2006-09-01 20:41:57 UTC (rev 10331)
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.3.5 on 01/09/06 20:33 */
+/* The following code was generated by JFlex 1.3.5 on 01/09/06 21:38 */

 package freenet.clients.http.filter;
 import java.io.*;
@@ -11,7 +11,7 @@
 /**
  * This class is a scanner generated by 
  * <a href="http://www.jflex.de/";>JFlex</a> 1.3.5
- * on 01/09/06 20:33 from the specification file
+ * on 01/09/06 21:38 from the specification file
  * <tt>file:/usr/src/cvs/eclipse-workspace/Freenet 
0.7/src/freenet/clients/http/filter/CSSTokenizerFilter.jflex</tt>
  */
 class CSSTokenizerFilter {
@@ -1399,31 +1399,6 @@
        if(debug) log("Matched function end: "+s);
  }
         case 325: break;
-        case 105: 
-          { 
-       String s = yytext();
-       StringBuffer sb = new StringBuffer(s.length());
-       sb.append("/* ");
-       boolean inPrefix = true;
-       for(int i=2;i<sb.length()-2;i++) {
-               char c = sb.charAt(i);
-               if(inPrefix && Character.isWhitespace(c)) {
-                       continue;
-               }
-               if(Character.isDigit(c) || Character.isWhitespace(c) ||
-                       Character.isLetter(c) || c == '.' || c == '_' || c == 
'-') {
-                       // No @, no !, etc; IE has been known to do things with 
comments
-                       // in CSS, and other browsers may too
-                       sb.append(c);
-               }
-       }
-       while(Character.isWhitespace(sb.charAt(sb.length()-1)))
-               sb.deleteCharAt(sb.length()-1);
-       sb.append(" */");
-       w.write(sb.toString());
-       if(debug) log("Matched comment: "+s+" -> "+sb.toString());
- }
-        case 326: break;
         case 248: 
         case 266: 
         case 280: 
@@ -1433,7 +1408,7 @@
        if(debug) log("Matched and ignoring charset: "+s);
        // Ignore
  }
-        case 327: break;
+        case 326: break;
         case 1: 
         case 3: 
         case 7: 
@@ -1450,21 +1425,21 @@
        log("Matched anything: "+yytext()+" - ignoring");
        w.write("/* ignored unmatched char: "+c+" */"); // single char cannot 
break out of comment
  }
-        case 328: break;
+        case 327: break;
         case 225: 
           { 
        String s = yytext();
        w.write(s);
        if(debug) log("Matched @font-face: "+s);
  }
-        case 329: break;
+        case 328: break;
         case 16: 
           { 
        String s = yytext();
        w.write(s);
        if(debug) log("Matched open braces: "+s);
  }
-        case 330: break;
+        case 329: break;
         case 6: 
         case 9: 
         case 12: 
@@ -1474,27 +1449,53 @@
        w.write(s);
        if(debug) log("Matched single char: "+s);
  }
-        case 331: break;
+        case 330: break;
         case 4: 
           { 
        String s = yytext();
        w.write(s);
        if(debug) log("Matched whitespace: "+s);
  }
-        case 332: break;
+        case 331: break;
         case 29: 
           { 
        String s = yytext();
        w.write(s);
        if(debug) log("Matched measurement: "+s);
  }
-        case 333: break;
+        case 332: break;
         case 58: 
           { 
        String s = yytext();
        w.write(s); 
        if(debug) log("Matched HTML comment: "+s);
  }
+        case 333: break;
+        case 105: 
+          { 
+       String s = yytext();
+       StringBuffer sb = new StringBuffer(s.length());
+       sb.append("/* comment: ");
+       boolean inPrefix = true;
+       for(int i=2;i<s.length()-2;i++) {
+               char c = s.charAt(i);
+               if(inPrefix && Character.isWhitespace(c)) {
+                       continue;
+               }
+               inPrefix = false;
+               if(Character.isDigit(c) || Character.isWhitespace(c) ||
+                       Character.isLetter(c) || c == '.' || c == '_' || c == 
'-') {
+                       // No @, no !, etc; IE has been known to do things with 
comments
+                       // in CSS, and other browsers may too
+                       sb.append(c);
+               }
+       }
+       while(Character.isWhitespace(sb.charAt(sb.length()-1)))
+               sb.deleteCharAt(sb.length()-1);
+       sb.append(" */");
+       w.write(sb.toString());
+       if(debug) log("Matched comment: "+s+" -> "+sb.toString());
+ }
         case 334: break;
         default: 
           if (yy_input == YYEOF && yy_startRead == yy_currentPos) {

Modified: trunk/freenet/src/freenet/clients/http/filter/CSSTokenizerFilter.jflex
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/CSSTokenizerFilter.jflex      
2006-09-01 20:32:42 UTC (rev 10330)
+++ trunk/freenet/src/freenet/clients/http/filter/CSSTokenizerFilter.jflex      
2006-09-01 20:41:57 UTC (rev 10331)
@@ -292,16 +292,18 @@
        w.write(s);
        if(debug) log("Matched whitespace: "+s);
 }
+//"/*"([^*]|[\r\n]|("*"+([^*/]|[\r\n])))*"*"*"/" {
 "/*" ~"*/" {
        String s = yytext();
        StringBuffer sb = new StringBuffer(s.length());
-       sb.append("/* ");
+       sb.append("/* comment: ");
        boolean inPrefix = true;
-       for(int i=2;i<sb.length()-2;i++) {
-               char c = sb.charAt(i);
+       for(int i=2;i<s.length()-2;i++) {
+               char c = s.charAt(i);
                if(inPrefix && Character.isWhitespace(c)) {
                        continue;
                }
+               inPrefix = false;
                if(Character.isDigit(c) || Character.isWhitespace(c) ||
                        Character.isLetter(c) || c == '.' || c == '_' || c == 
'-') {
                        // No @, no !, etc; IE has been known to do things with 
comments

Modified: trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java       
2006-09-01 20:32:42 UTC (rev 10330)
+++ trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java       
2006-09-01 20:41:57 UTC (rev 10331)
@@ -288,6 +288,10 @@
                                                                saveComment(b, 
w, this);
                                                                b = new 
StringBuffer(100);
                                                                mode = INTEXT;
+                                                       } else {
+                                                               b.append(c);
+                                                               if(c != '-')
+                                                                       mode = 
INTAGCOMMENT;
                                                        }
                                                        break;
                                                case INTAGWHITESPACE :


Reply via email to