Changeset 201863 in webkit
- Timestamp:
- Jun 9, 2016, 7:54:50 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/text/dangling-surrogates-expected.txt (added)
-
LayoutTests/fast/text/dangling-surrogates.html (added)
-
Source/WebKit2/ChangeLog (modified) (1 diff)
-
Source/WebKit2/Shared/API/c/WKString.cpp (modified) (3 diffs)
-
Source/WebKit2/Shared/API/c/WKString.h (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/DumpRenderTree/mac/DumpRenderTree.mm (modified) (2 diffs)
-
Tools/WebKitTestRunner/StringFunctions.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r201861 r201863 1 2016-06-09 Michael Saboff <msaboff@apple.com> 2 3 WebKitTestRunner and DumpRenderTree do not handle dangling surrogate characters 4 https://bugs.webkit.org/show_bug.cgi?id=154863 5 6 Reviewed by Alexey Proskuryakov. 7 8 New tests. 9 10 * fast/text/dangling-surrogates-expected.txt: Added. 11 * fast/text/dangling-surrogates.html: Added. 12 1 13 2016-06-09 Commit Queue <commit-queue@webkit.org> 2 14 -
trunk/Source/WebKit2/ChangeLog
r201860 r201863 1 2016-06-09 Michael Saboff <msaboff@apple.com> 2 3 WebKitTestRunner and DumpRenderTree do not handle dangling surrogate characters 4 https://bugs.webkit.org/show_bug.cgi?id=154863 5 6 Reviewed by Alexey Proskuryakov. 7 8 Added a non-strict verions of WKStringGetUTF8CString() that will handle dangling 9 surrogates called WKStringGetUTF8CStringNonStrict(). 10 11 * Shared/API/c/WKString.cpp: 12 (WKStringGetUTF8CStringImpl): 13 (WKStringGetUTF8CString): 14 (WKStringGetUTF8CStringNonStrict): 15 * Shared/API/c/WKString.h: 16 1 17 2016-06-09 Carlos Garcia Campos <cgarcia@igalia.com> 2 18 -
trunk/Source/WebKit2/Shared/API/c/WKString.cpp
r195743 r201863 71 71 } 72 72 73 size_t WKStringGetUTF8CString(WKStringRef stringRef, char* buffer, size_t bufferSize) 73 enum StrictType { NonStrict = false, Strict = true }; 74 75 template <StrictType strict> 76 size_t WKStringGetUTF8CStringImpl(WKStringRef stringRef, char* buffer, size_t bufferSize) 74 77 { 75 78 if (!bufferSize) … … 86 89 } else { 87 90 const UChar* characters = stringView.characters16(); 88 result = WTF::Unicode::convertUTF16ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1, /* strict */ true);91 result = WTF::Unicode::convertUTF16ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1, strict); 89 92 } 90 93 … … 94 97 *p++ = '\0'; 95 98 return p - buffer; 99 } 100 101 size_t WKStringGetUTF8CString(WKStringRef stringRef, char* buffer, size_t bufferSize) 102 { 103 return WKStringGetUTF8CStringImpl<StrictType::Strict>(stringRef, buffer, bufferSize); 104 } 105 106 size_t WKStringGetUTF8CStringNonStrict(WKStringRef stringRef, char* buffer, size_t bufferSize) 107 { 108 return WKStringGetUTF8CStringImpl<StrictType::NonStrict>(stringRef, buffer, bufferSize); 96 109 } 97 110 -
trunk/Source/WebKit2/Shared/API/c/WKString.h
r168541 r201863 56 56 WK_EXPORT size_t WKStringGetMaximumUTF8CStringSize(WKStringRef string); 57 57 WK_EXPORT size_t WKStringGetUTF8CString(WKStringRef string, char* buffer, size_t bufferSize); 58 WK_EXPORT size_t WKStringGetUTF8CStringNonStrict(WKStringRef string, char* buffer, size_t bufferSize); 58 59 59 60 WK_EXPORT bool WKStringIsEqual(WKStringRef a, WKStringRef b); -
trunk/Tools/ChangeLog
r201849 r201863 1 2016-06-09 Michael Saboff <msaboff@apple.com> 2 3 WebKitTestRunner and DumpRenderTree do not handle dangling surrogate characters 4 https://bugs.webkit.org/show_bug.cgi?id=154863 5 6 Reviewed by Alexey Proskuryakov. 7 8 Added a non-strict verions of WKStringGetUTF8CString() that will handle dangling 9 surrogates. Changed the extraction of inner text from frames in DumpRenderTree 10 to use the new WKStringGetUTF8CStringNonStrict() function instead of NSString 11 conversion since NSString doesn't have a way to handle dangling surrogates. 12 The code added in DumpRenderTree matches what was changed in WebKitTestRunner. 13 14 * DumpRenderTree/mac/DumpRenderTree.mm: 15 (dumpFramesAsText): 16 * WebKitTestRunner/StringFunctions.h: 17 (WTR::toWTFString): 18 1 19 2016-06-08 Hunseop Jeong <hs85.jeong@samsung.com> 2 20 -
trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm
r201404 r201863 63 63 #import <WebKit/DOMExtensions.h> 64 64 #import <WebKit/DOMRange.h> 65 #import <WebKit/WKString.h> 66 #import <WebKit/WKStringCF.h> 65 67 #import <WebKit/WebArchive.h> 66 68 #import <WebKit/WebBackForwardList.h> … … 1524 1526 result = [NSMutableString stringWithFormat:@"\n--------\nFrame: '%@'\n--------\n", [frame name]]; 1525 1527 1526 [result appendFormat:@"%@\n", [documentElement innerText]]; 1528 NSString *innerText = [documentElement innerText]; 1529 // We use WKStringGetUTF8CStringNonStrict() to convert innerText to a WK String since 1530 // WKStringGetUTF8CStringNonStrict() can handle dangling surrogates and the NSString 1531 // conversion methods cannot. After the conversion to a buffer, we turn that buffer into 1532 // a CFString via fromUTF8WithLatin1Fallback().createCFString() which can be appended to 1533 // the result without any conversion. 1534 WKStringRef stringRef = WKStringCreateWithCFString((CFStringRef)innerText); 1535 size_t bufferSize = WKStringGetMaximumUTF8CStringSize(stringRef); 1536 auto buffer = std::make_unique<char[]>(bufferSize); 1537 size_t stringLength = WKStringGetUTF8CStringNonStrict(stringRef, buffer.get(), bufferSize); 1538 [result appendFormat:@"%@\n", String::fromUTF8WithLatin1Fallback(buffer.get(), stringLength - 1).createCFString().get()]; 1527 1539 1528 1540 if (gTestRunner->dumpChildFramesAsText()) { -
trunk/Tools/WebKitTestRunner/StringFunctions.h
r168961 r201863 88 88 size_t bufferSize = WKStringGetMaximumUTF8CStringSize(string); 89 89 auto buffer = std::make_unique<char[]>(bufferSize); 90 size_t stringLength = WKStringGetUTF8CString (string, buffer.get(), bufferSize);90 size_t stringLength = WKStringGetUTF8CStringNonStrict(string, buffer.get(), bufferSize); 91 91 return WTF::String::fromUTF8WithLatin1Fallback(buffer.get(), stringLength - 1); 92 92 }
Note:
See TracChangeset
for help on using the changeset viewer.