[webkit-changes] cvs commit: LayoutTests/fast/forms form-data-encoding-expected.txt form-data-encoding.html

Darin darin at opensource.apple.com
Sat Oct 8 20:31:12 PDT 2005


darin       05/10/08 20:31:11

  Modified:    .        ChangeLog
               khtml/html html_formimpl.cpp
               kwq      KWQTextCodec.h KWQTextCodec.mm
               .        ChangeLog
  Added:       fast/forms form-data-encoding-expected.txt
                        form-data-encoding.html
  Log:
  LayoutTests:
  
          - Added a test for http://bugzilla.opendarwin.org/show_bug.cgi?id=4821
            Text in submitted forms should be entity-encoded if the current encoding doesn't support it
  
          * fast/forms/form-data-encoding-expected.txt: Added.
          * fast/forms/form-data-encoding.html: Added.
  
  WebCore:
  
          Reviewed by Maciej.
  
          - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4821
            Text in submitted forms should be entity-encoded if the current encoding doesn't support it
  
          Added one layout test.
  
          * khtml/html/html_formimpl.cpp:
          (DOM::HTMLFormElementImpl::formData): Pass true to the fromUnicode function to request entity encoding.
          (DOM::FormDataList::appendString): Ditto.
  
          * kwq/KWQTextCodec.h: Add boolean parameter to request entity-style encoding for characters that can't
          be expressed in the desired encoding.
          * kwq/KWQTextCodec.mm: (QTextCodec::fromUnicode): Added code to entity-encode characters that can't be
          expressed in the desired encoding.
  
  Revision  Changes    Path
  1.224     +18 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.223
  retrieving revision 1.224
  diff -u -r1.223 -r1.224
  --- ChangeLog	9 Oct 2005 02:36:11 -0000	1.223
  +++ ChangeLog	9 Oct 2005 03:31:07 -0000	1.224
  @@ -1,3 +1,21 @@
  +2005-10-08  Alexey Proskuryakov  <ap at nypop.com>
  +
  +        Reviewed by Maciej.
  +
  +        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4821
  +          Text in submitted forms should be entity-encoded if the current encoding doesn't support it
  +
  +        Added one layout test.
  +
  +        * khtml/html/html_formimpl.cpp:
  +        (DOM::HTMLFormElementImpl::formData): Pass true to the fromUnicode function to request entity encoding.
  +        (DOM::FormDataList::appendString): Ditto.
  +
  +        * kwq/KWQTextCodec.h: Add boolean parameter to request entity-style encoding for characters that can't
  +        be expressed in the desired encoding.
  +        * kwq/KWQTextCodec.mm: (QTextCodec::fromUnicode): Added code to entity-encode characters that can't be
  +        expressed in the desired encoding.
  +
   2005-10-08  Rosyna  <rosyna at unsanity.com>
   
           Reviewed by Darin.
  
  
  
  1.198     +2 -2      WebCore/khtml/html/html_formimpl.cpp
  
  Index: html_formimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.cpp,v
  retrieving revision 1.197
  retrieving revision 1.198
  diff -u -r1.197 -r1.198
  --- html_formimpl.cpp	3 Oct 2005 21:34:47 -0000	1.197
  +++ html_formimpl.cpp	9 Oct 2005 03:31:09 -0000	1.198
  @@ -416,7 +416,7 @@
                           // things if the filename includes characters you can't encode
                           // in the website's character set.
                           hstr += "; filename=\"";
  -                        hstr += codec->fromUnicode(path.mid(path.findRev('/') + 1));
  +                        hstr += codec->fromUnicode(path.mid(path.findRev('/') + 1), true);
                           hstr += "\"";
   
                           if(!static_cast<HTMLInputElementImpl*>(current)->value().isEmpty())
  @@ -3880,7 +3880,7 @@
   
   void FormDataList::appendString(const QString &s)
   {
  -    QCString cstr = fixLineBreaks(m_codec->fromUnicode(s));
  +    QCString cstr = fixLineBreaks(m_codec->fromUnicode(s, true));
       cstr.truncate(cstr.length());
       m_list.append(cstr);
   }
  
  
  
  1.26      +1 -1      WebCore/kwq/KWQTextCodec.h
  
  Index: KWQTextCodec.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQTextCodec.h,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- KWQTextCodec.h	27 Apr 2004 04:20:09 -0000	1.25
  +++ KWQTextCodec.h	9 Oct 2005 03:31:10 -0000	1.26
  @@ -48,7 +48,7 @@
   
       QTextDecoder *makeDecoder() const;
   
  -    QCString fromUnicode(const QString &) const;
  +    QCString fromUnicode(const QString &str, bool allowEntities = false) const;
   
       QString toUnicode(const char *, int) const;
       QString toUnicode(const QByteArray &, int) const;
  
  
  
  1.57      +29 -8     WebCore/kwq/KWQTextCodec.mm
  
  Index: KWQTextCodec.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQTextCodec.mm,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- KWQTextCodec.mm	3 Oct 2005 21:13:10 -0000	1.56
  +++ KWQTextCodec.mm	9 Oct 2005 03:31:10 -0000	1.57
  @@ -145,7 +145,7 @@
       return e;
   }
   
  -QCString QTextCodec::fromUnicode(const QString &qcs) const
  +QCString QTextCodec::fromUnicode(const QString &qcs, bool allowEntities) const
   {
       // FIXME: We should really use the same API in both directions.
       // Currently we use ICU to decode and CFString to encode; it would be better to encode with ICU too.
  @@ -157,13 +157,34 @@
       QString copy = qcs;
       copy.replace(QChar('\\'), backslashAsCurrencySymbol());
       CFStringRef cfs = copy.getCFString();
  -
  -    CFRange range = CFRangeMake(0, CFStringGetLength(cfs));
  -    CFIndex bufferLength;
  -    CFStringGetBytes(cfs, range, encoding, '?', FALSE, NULL, 0x7FFFFFFF, &bufferLength);
  -    QCString result(bufferLength + 1);
  -    CFStringGetBytes(cfs, range, encoding, '?', FALSE, reinterpret_cast<unsigned char *>(result.data()), bufferLength, &bufferLength);
  -    result[bufferLength] = 0;
  +    
  +    CFIndex startPos = 0;
  +    CFIndex charactersLeft = CFStringGetLength(cfs);
  +    QCString result(1); // for trailng zero
  +
  +    while (charactersLeft > 0) {
  +        CFRange range = CFRangeMake(startPos, charactersLeft);
  +        CFIndex bufferLength;
  +        CFStringGetBytes(cfs, range, encoding, allowEntities ? 0 : '?', FALSE, NULL, 0x7FFFFFFF, &bufferLength);
  +        
  +        QCString chunk(bufferLength + 1);
  +        CFIndex charactersConverted = CFStringGetBytes(cfs, range, encoding, allowEntities ? 0 : '?', FALSE, reinterpret_cast<unsigned char *>(chunk.data()), bufferLength, &bufferLength);
  +        chunk[bufferLength] = 0;
  +        result.append(chunk);
  +        
  +        if (charactersConverted != charactersLeft) {
  +            // FIXME: support surrogate pairs
  +            UniChar badChar = CFStringGetCharacterAtIndex(cfs, startPos + charactersConverted);
  +            char buf[16];
  +            sprintf(buf, "&#%u;", badChar);
  +            result.append(buf);
  +            
  +            ++charactersConverted;
  +        }
  +        
  +        startPos += charactersConverted;
  +        charactersLeft -= charactersConverted;
  +    }
       return result;
   }
   
  
  
  
  1.22      +8 -0      LayoutTests/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/LayoutTests/ChangeLog,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- ChangeLog	9 Oct 2005 02:57:21 -0000	1.21
  +++ ChangeLog	9 Oct 2005 03:31:11 -0000	1.22
  @@ -1,5 +1,13 @@
   2005-10-08  Alexey Proskuryakov  <ap at nypop.com>
   
  +        - Added a test for http://bugzilla.opendarwin.org/show_bug.cgi?id=4821
  +          Text in submitted forms should be entity-encoded if the current encoding doesn't support it
  +
  +        * fast/forms/form-data-encoding-expected.txt: Added.
  +        * fast/forms/form-data-encoding.html: Added.
  +
  +2005-10-08  Alexey Proskuryakov  <ap at nypop.com>
  +
           Reviewed by Darin.
   
           - Added a test for http://bugzilla.opendarwin.org/show_bug.cgi?id=4707
  
  
  
  1.1                  LayoutTests/fast/forms/form-data-encoding-expected.txt
  
  Index: form-data-encoding-expected.txt
  ===================================================================
  
  Success
  
  
  
  
  
  1.1                  LayoutTests/fast/forms/form-data-encoding.html
  
  Index: form-data-encoding.html
  ===================================================================
  <html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
  <title>Charsets and submitting forms</title>
  </head>
  <body>
  <form action="?" name=f>
   <input type=hidden name=q value="&#1090;&#1077;&#1089;&#1090;"><br>
  </form>
  <script>
  if (window.layoutTestController) {
  	layoutTestController.dumpAsText();
  	layoutTestController.waitUntilDone();
  }
  
  if (document.URL.substring(0, 4) == "file") {
  
  	if (document.URL.indexOf('?') == -1) {
  
  		document.f.submit();
  
  	} else {
  		
  		if (unescape(document.URL.substring(document.URL.indexOf('?')+1, document.URL.length)) == unescape("q=%26%231090%3B%26%231077%3B%26%231089%3B%26%231090%3B"))
  			document.write("<p>Success</p>");
  		else
  			document.write("<p>Failure</p>");
  		
  		if (window.layoutTestController)
  			layoutTestController.notifyDone();
  	}
  
  } else {
  
  	document.write("<p>This test doesn't work directly from bugzilla, please save it to a local file first.</p>");
  }
  </script>
  </body>
  </html>
  
  



More information about the webkit-changes mailing list