WebKit Bugzilla
Attachment 358027 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-20181222184814.patch (text/plain), 2.91 KB, created by
Michael Catanzaro
on 2018-12-22 16:48:15 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Michael Catanzaro
Created:
2018-12-22 16:48:15 PST
Size:
2.91 KB
patch
obsolete
>Subversion Revision: 239541 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 181e6b2f9f57ad4eaab5b5f036f344bced1816a1..457fd0e1bffeefb79a10384218bcbd310930ae5b 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,19 @@ >+2018-12-22 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-21 Dan Bernstein <mitz@apple.com> > > Fixed building for macOS 10.13 using the macOS 10.14 SDK. >diff --git a/Source/WTF/wtf/cocoa/NSURLExtras.mm b/Source/WTF/wtf/cocoa/NSURLExtras.mm >index d57b9951a07f96a2cebdb977f68e919b18c6bea8..0c02b1b6503d3a6afba4ad4690c91931e5d932be 100644 >--- a/Source/WTF/wtf/cocoa/NSURLExtras.mm >+++ b/Source/WTF/wtf/cocoa/NSURLExtras.mm >@@ -39,6 +39,7 @@ > #import <wtf/Vector.h> > #import <unicode/uchar.h> > #import <unicode/uidna.h> >+#import <unicode/unorm.h> > #import <unicode/uscript.h> > > // Needs to be big enough to hold an IDN-encoded name. >@@ -1165,7 +1166,26 @@ NSString *userVisibleString(NSURL *URL) > result = mappedResult; > } > >- result = [result precomposedStringWithCanonicalMapping]; >+ auto sourceBuffer = String(result.get()).charactersWithNullTermination(); >+ ASSERT(sourceBuffer.last() == '\0'); >+ sourceBuffer.removeLast(); >+ >+ result = [NSString string]; >+ Vector<UChar, URL_BYTES_BUFFER_LENGTH> normalizedCharacters(sourceBuffer.size()); >+ UErrorCode uerror = U_ZERO_ERROR; >+ int32_t normalizedLength = 0; >+ const UNormalizer2 *normalizer = unorm2_getNFCInstance(&uerror); >+ if (!U_FAILURE(uerror)) { >+ 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 = [[NSString alloc] 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