Changeset 14217 in webkit
- Timestamp:
- May 7, 2006 11:01:59 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r14211 r14217 1 2006-05-07 Alexey Proskuryakov <ap@nypop.com> 2 3 Reviewed by Darin. 4 5 - Tests for http://bugzilla.opendarwin.org/show_bug.cgi?id=8769 6 TextEncoding::fromUnicode() - support non-BMP characters and convert to NFC 7 8 * fast/forms/form-data-encoding.html: Cover more cases for Latin-1 encoding. 9 * fast/forms/form-data-encoding-2.html: Added. Test conversion to UTF-8. 10 * fast/forms/form-data-encoding-2-expected.txt: Added. 11 1 12 2006-05-05 Alexey Proskuryakov <ap@nypop.com> 2 13 -
trunk/LayoutTests/fast/forms/form-data-encoding.html
r11995 r14217 6 6 <body> 7 7 <form action="?" name=f> 8 <input type=hidden name=q value=" 090;ест"><br>8 <input type=hidden name=q value="ё𐐀𝄫çc"><br> 9 9 </form> 10 10 <script> 11 11 if (window.layoutTestController) { 12 13 12 layoutTestController.dumpAsText(); 13 layoutTestController.waitUntilDone(); 14 14 } 15 15 16 16 if (document.URL.substring(0, 4) == "file") { 17 17 18 if (document.URL.indexOf('?') == -1) { 18 if (document.URL.indexOf('?') == -1) { 19 document.f.q.value += "\u0327"; // cedilla for 'c' 20 document.f.submit(); 19 21 20 document.f.submit(); 21 22 } else { 23 24 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")) 25 document.write("<p>Success</p>"); 26 else 27 document.write("<p>Failure</p>"); 28 29 if (window.layoutTestController) 30 layoutTestController.notifyDone(); 31 } 22 } else { 23 if (unescape(document.URL.substring(document.URL.indexOf('?')+1, document.URL.length)) == unescape("q=%26%231105%3B%26%2366560%3B%26%23119083%3B%E7%E7")) 24 document.write("<p>Success</p>"); 25 else 26 document.write("<p>Failure</p>"); 27 28 if (window.layoutTestController) 29 layoutTestController.notifyDone(); 30 } 32 31 33 32 } else { 34 33 35 34 document.write("<p>This test doesn't work directly from bugzilla, please save it to a local file first.</p>"); 36 35 } 37 36 </script> -
trunk/WebCore/ChangeLog
r14216 r14217 1 2006-05-07 Alexey Proskuryakov <ap@nypop.com> 2 3 Reviewed by Darin. 4 5 - http://bugzilla.opendarwin.org/show_bug.cgi?id=8769 6 TextEncoding::fromUnicode() - support non-BMP characters and convert to NFC 7 8 Tests: 9 * fast/forms/forms/form-data-encoding.html 10 * fast/forms/forms/form-data-encoding-2.html 11 12 * platform/mac/TextEncodingMac.cpp: 13 (WebCore::TextEncoding::fromUnicode): Normalize the string; handle surrogate pairs. 14 1 15 2006-05-06 David Hyatt <hyatt@apple.com> 2 16 -
trunk/WebCore/platform/mac/TextEncodingMac.cpp
r13901 r14217 54 54 copy.replace(QChar('\\'), backslashAsCurrencySymbol()); 55 55 CFStringRef cfs = copy.getCFString(); 56 CFMutableStringRef cfms = CFStringCreateMutableCopy(0, 0, cfs); // in rare cases, normalization can make the string longer, thus no limit on its length 57 CFStringNormalize(cfms, kCFStringNormalizationFormC); 56 58 57 59 CFIndex startPos = 0; 58 CFIndex charactersLeft = CFStringGetLength(cf s);59 DeprecatedCString result(1); // for trail ng zero60 CFIndex charactersLeft = CFStringGetLength(cfms); 61 DeprecatedCString result(1); // for trailing zero 60 62 61 63 while (charactersLeft > 0) { 62 64 CFRange range = CFRangeMake(startPos, charactersLeft); 63 65 CFIndex bufferLength; 64 CFStringGetBytes(cf s, range, encoding, allowEntities ? 0 : '?', false, NULL, 0x7FFFFFFF, &bufferLength);66 CFStringGetBytes(cfms, range, encoding, allowEntities ? 0 : '?', false, NULL, 0x7FFFFFFF, &bufferLength); 65 67 66 68 DeprecatedCString chunk(bufferLength + 1); 67 69 unsigned char *buffer = reinterpret_cast<unsigned char *>(chunk.data()); 68 CFIndex charactersConverted = CFStringGetBytes(cf s, range, encoding, allowEntities ? 0 : '?', false, buffer, bufferLength, &bufferLength);70 CFIndex charactersConverted = CFStringGetBytes(cfms, range, encoding, allowEntities ? 0 : '?', false, buffer, bufferLength, &bufferLength); 69 71 buffer[bufferLength] = 0; 70 72 result.append(chunk); 71 73 72 74 if (charactersConverted != charactersLeft) { 73 // FIXME: support surrogate pairs 74 UniChar badChar = CFStringGetCharacterAtIndex(cfs, startPos + charactersConverted); 75 unsigned int badChar = CFStringGetCharacterAtIndex(cfms, startPos + charactersConverted); 76 ++charactersConverted; 77 78 if ((badChar & 0xfc00) == 0xd800 && // is high surrogate 79 charactersConverted != charactersLeft) { 80 UniChar low = CFStringGetCharacterAtIndex(cfms, startPos + charactersConverted); 81 if ((low & 0xfc00) == 0xdc00) { // is low surrogate 82 badChar <<= 10; 83 badChar += low; 84 badChar += 0x10000 - (0xd800 << 10) - 0xdc00; 85 ++charactersConverted; 86 } 87 } 75 88 char buf[16]; 76 89 sprintf(buf, "&#%u;", badChar); 77 90 result.append(buf); 78 79 ++charactersConverted;80 91 } 81 92 … … 83 94 charactersLeft -= charactersConverted; 84 95 } 96 CFRelease(cfms); 85 97 return result; 86 98 }
Note: See TracChangeset
for help on using the changeset viewer.