[webkit-changes] cvs commit: WebCore/khtml/html htmltokenizer.cpp

David hyatt at opensource.apple.com
Fri Aug 26 17:12:34 PDT 2005


hyatt       05/08/26 17:12:34

  Modified:    .        ChangeLog
               khtml/html htmltokenizer.cpp
  Log:
  	Fix comment parsing so that it is lax for <style>.  Better fix eventually
  	will be to not even have the tokenizer do anything with <!-- and --> inside
  	<style> and <script>.
  
          Reviewed by adele
  
          * khtml/html/htmltokenizer.cpp:
          (khtml::HTMLTokenizer::parseComment):
  
  Revision  Changes    Path
  1.17      +11 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ChangeLog	26 Aug 2005 22:39:32 -0000	1.16
  +++ ChangeLog	27 Aug 2005 00:12:33 -0000	1.17
  @@ -1,3 +1,14 @@
  +2005-08-26  David Hyatt  <hyatt at apple.com>
  +
  +	Fix comment parsing so that it is lax for <style>.  Better fix eventually
  +	will be to not even have the tokenizer do anything with <!-- and --> inside
  +	<style> and <script>.
  +	
  +        Reviewed by adele
  +
  +        * khtml/html/htmltokenizer.cpp:
  +        (khtml::HTMLTokenizer::parseComment):
  +        
   2005-08-26  John Sullivan  <sullivan at apple.com>
   
           Reviewed by Darin Adler.
  
  
  
  1.109     +16 -24    WebCore/khtml/html/htmltokenizer.cpp
  
  Index: htmltokenizer.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/htmltokenizer.cpp,v
  retrieving revision 1.108
  retrieving revision 1.109
  diff -u -r1.108 -r1.109
  --- htmltokenizer.cpp	25 Aug 2005 23:13:50 -0000	1.108
  +++ htmltokenizer.cpp	27 Aug 2005 00:12:33 -0000	1.109
  @@ -574,8 +574,8 @@
   
   void HTMLTokenizer::parseComment(TokenizerString &src)
   {
  -    // FIXME: Why does this code even run for comments inside <script>? This seems bogus.
  -    bool strict = !parser->doc()->inCompatMode() && !script;
  +    // FIXME: Why does this code even run for comments inside <script> and <style>? This seems bogus.
  +    bool strict = !parser->doc()->inCompatMode() && !script && !style;
       int delimiterCount = 0;
       bool canClose = false;
       checkScriptBuffer(src.length());
  @@ -583,10 +583,22 @@
           scriptCode[ scriptCodeSize++ ] = *src;
   #if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 1
           qDebug("comment is now: *%s*",
  -               QConstString((QChar*)src.current(), kMin(16, src.length())).qstring().latin1());
  +               QConstString((QChar*)src.current(), kMin(16, src.length())).string().latin1());
   #endif
   
  -        if ((!strict || canClose) && *src == '>') {
  +        if (strict) {
  +            if (src->unicode() == '-') {
  +                delimiterCount++;
  +                if (delimiterCount == 2) {
  +                    delimiterCount = 0;
  +                    canClose = !canClose;
  +                }
  +            }
  +            else
  +                delimiterCount = 0;
  +        }
  +
  +        if ((!strict || canClose) && src->unicode() == '>') {
               bool handleBrokenComments = brokenComments && !(script || style);
               int endCharsCount = 1; // start off with one for the '>' character
               if (!strict) {
  @@ -622,26 +634,6 @@
                   return; // Finished parsing comment
               }
           }
  -
  -        if (strict) {
  -            if (*src == '-') {
  -                delimiterCount++;
  -                if (delimiterCount == 2) {
  -                    delimiterCount = 0;
  -                    canClose = !canClose;
  -                }
  -            } else {
  -                delimiterCount = 0;
  -                // Bad markup.  Non-space between the comment end and the markup
  -                // declaration close ('>').  Keep scanning as comment, but set
  -                // the state back to where we need to see another comment end
  -                // followed by a declaration close.
  -                // This is not exactly to spec, but is better for compatiblility.
  -                if (canClose && *src != ' ')
  -                    canClose = false;
  -            }
  -        }
  -
           ++src;
       }
   }
  
  
  



More information about the webkit-changes mailing list