WebKit Bugzilla
Attachment 359107 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-20190114194124.patch (text/plain), 3.39 KB, created by
Michael Catanzaro
on 2019-01-14 17:41:25 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Michael Catanzaro
Created:
2019-01-14 17:41:25 PST
Size:
3.39 KB
patch
obsolete
>Subversion Revision: 239963 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 9d0ae3e32516ae332c14a4e3a7c38adf5d74ab59..22169c2cf83dc1f5f5725df56cd67c6543c30b63 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,20 @@ >+2019-01-14 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::toNormalizationFormC): >+ (WTF::userVisibleString): >+ > 2019-01-12 Timothy Hatcher <timothy@apple.com> > > Have prefers-color-scheme: light always match on macOS versions before Mojave. >diff --git a/Source/WTF/wtf/cocoa/NSURLExtras.mm b/Source/WTF/wtf/cocoa/NSURLExtras.mm >index 8622700aecf12c0c4c87a5954016238b34d4eaca..dad9d624b75793ab675050ead01ca1db529c3fb8 100644 >--- a/Source/WTF/wtf/cocoa/NSURLExtras.mm >+++ b/Source/WTF/wtf/cocoa/NSURLExtras.mm >@@ -32,6 +32,7 @@ > > #import <unicode/uchar.h> > #import <unicode/uidna.h> >+#import <unicode/unorm.h> > #import <unicode/uscript.h> > #import <wtf/Function.h> > #import <wtf/HexNumber.h> >@@ -1095,6 +1096,31 @@ static CFStringRef createStringWithEscapedUnsafeCharacters(CFStringRef string) > return CFStringCreateWithCharacters(nullptr, outBuffer.data(), outBuffer.size()); > } > >+static String toNormalizationFormC(const String& string) >+{ >+ auto sourceBuffer = string.charactersWithNullTermination(); >+ ASSERT(sourceBuffer.last() == '\0'); >+ sourceBuffer.removeLast(); >+ >+ String result; >+ 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 = String(normalizedCharacters.data(), normalizedLength); >+ } >+ >+ return result; >+} >+ > NSString *userVisibleString(NSURL *URL) > { > NSData *data = originalURLData(URL); >@@ -1165,7 +1191,9 @@ NSString *userVisibleString(NSURL *URL) > result = mappedResult; > } > >- result = [result precomposedStringWithCanonicalMapping]; >+ auto wtfString = String(result.get()); >+ auto normalized = toNormalizationFormC(wtfString); >+ result = static_cast<NSString *>(normalized); > 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
Flags:
achristensen
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192945
:
357853
|
357856
|
357858
|
357862
|
357865
|
358027
| 359107