WebKit Bugzilla
Attachment 357853 Details for
Bug 192945
: Use unorm2_normalize instead of precomposedStringWithCanonicalMapping in userVisibleString
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192945-20181220150213.patch (text/plain), 2.64 KB, created by
Michael Catanzaro
on 2018-12-20 13:02:14 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Michael Catanzaro
Created:
2018-12-20 13:02:14 PST
Size:
2.64 KB
patch
obsolete
>Subversion Revision: 239428 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 64ddbd43e28acba272971e9f358e2b6444a5bc2e..92c2f2cc7a22ab099c6d3ecc1738bfc0856d8fa2 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,19 @@ >+2018-12-20 Michael Catanzaro <mcatanzaro@igalia.com> >+ >+ Use unorm2_normalize instead of precomposedStringWithCanonicalMapping in userVisibleString >+ https://bugs.webkit.org/show_bug.cgi?id=192945 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Replace use of the nice NSString function precomposedStringWithCanonicalMapping with the ICU >+ API unorm2_normalize. This is to prep the code for translation to cross-platform C++. Of >+ course this is much worse than the preexisting code, but this is just a transitional >+ measure and not the final state of the code. It wouldn't make sense to do this if the code >+ were to remain Objective C++. >+ >+ * wtf/cocoa/NSURLExtras.mm: >+ (WTF::userVisibleString): >+ > 2018-12-19 Chris Dumez <cdumez@apple.com> > > wtf/Optional.h: move-constructor and move-assignment operator should disengage the value being moved from >diff --git a/Source/WTF/wtf/cocoa/NSURLExtras.mm b/Source/WTF/wtf/cocoa/NSURLExtras.mm >index d57b9951a07f96a2cebdb977f68e919b18c6bea8..b34404f495adac27323613b42c093e5e1ba1c7bf 100644 >--- a/Source/WTF/wtf/cocoa/NSURLExtras.mm >+++ b/Source/WTF/wtf/cocoa/NSURLExtras.mm >@@ -1165,7 +1165,24 @@ NSString *userVisibleString(NSURL *URL) > result = mappedResult; > } > >- result = [result precomposedStringWithCanonicalMapping]; >+ auto sourceBuffer = String(result).charactersWithNullTermination(); >+ ASSERT(sourceBuffer.last() == '\0'); >+ sourceBuffer.removeLast(); >+ >+ Vector<UChar, urlBytesBufferLength> normalizedCharacters(sourceBuffer.size()); >+ UErrorCode uerror = U_ZERO_ERROR; >+ const UNormalizer2 *normalizer = unorm2_getNFCInstance(&uerror); >+ int32_t normalizedLength = unorm2_normalize(normalizer, sourceBuffer.data(), sourceBuffer.size(), normalizedCharacters.data(), normalizedCharacters.size(), &uerror); >+ if (uerror == U_BUFFER_OVERFLOW_ERROR) { >+ uerror = U_ZERO_ERROR; >+ normalizedCharacters.resize(normalizedLength); >+ normalizedLength = unorm2_normalize(normalizer, sourceBuffer.data(), sourceBuffer.size(), normalizedCharacters.data(), normalizedLength, &uerror); >+ } >+ if (U_FAILURE(uerror)) >+ result = string; >+ else >+ result = [NSString initWithCharacters:normalizedCharacters.data(), length:normalizedLength]; >+ > return CFBridgingRelease(createStringWithEscapedUnsafeCharacters((__bridge CFStringRef)result.get())); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192945
:
357853
|
357856
|
357858
|
357862
|
357865
|
358027
|
359107