Don't read from WebCore's bundle for IDNScriptWhiteList
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Oct 2018 00:21:14 +0000 (00:21 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Oct 2018 00:21:14 +0000 (00:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190157

Reviewed by Dan Bernstein.

No change in behavior.  This increases performance by not reading from the WebCore bundle,
and it makes it so that URL-related functionality can be moved to a place without
a bundle for resources.

* Resources/IDNScriptWhiteList.txt: Removed.
* WebCore.xcodeproj/project.pbxproj:
* platform/mac/WebCoreNSURLExtras.mm:
(WebCore::whiteListIDNScripts):
(WebCore::allCharactersInIDNScriptWhiteList):
(WebCore::readIDNScriptWhiteListFile): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236703 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Resources/IDNScriptWhiteList.txt [deleted file]
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/mac/WebCoreNSURLExtras.mm

index a6d4238..083cab3 100644 (file)
@@ -1,5 +1,23 @@
 2018-10-01  Alex Christensen  <achristensen@webkit.org>
 
+        Don't read from WebCore's bundle for IDNScriptWhiteList
+        https://bugs.webkit.org/show_bug.cgi?id=190157
+
+        Reviewed by Dan Bernstein.
+
+        No change in behavior.  This increases performance by not reading from the WebCore bundle,
+        and it makes it so that URL-related functionality can be moved to a place without
+        a bundle for resources.
+
+        * Resources/IDNScriptWhiteList.txt: Removed.
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/mac/WebCoreNSURLExtras.mm:
+        (WebCore::whiteListIDNScripts):
+        (WebCore::allCharactersInIDNScriptWhiteList):
+        (WebCore::readIDNScriptWhiteListFile): Deleted.
+
+2018-10-01  Alex Christensen  <achristensen@webkit.org>
+
         Unreviewed, rolling out r236551.
 
         Fails URL validating too aggressively
diff --git a/Source/WebCore/Resources/IDNScriptWhiteList.txt b/Source/WebCore/Resources/IDNScriptWhiteList.txt
deleted file mode 100644 (file)
index d635a34..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-# Default Web Kit International Domain Name Script White List.
-
-Common
-Inherited
-
-Arabic
-Armenian
-Bopomofo
-Canadian_Aboriginal
-Devanagari
-Deseret
-Gujarati
-Gurmukhi
-Hangul
-Han
-Hebrew
-Hiragana
-Katakana_Or_Hiragana
-Katakana
-Latin
-Tamil
-Thai
-Yi
index 5aa39bf..5e15fce 100644 (file)
                7CC2DE031ECA04A50027B774 /* NotificationDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC2DE021ECA04A50027B774 /* NotificationDirection.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7CC564B818BABEA6001B9652 /* TelephoneNumberDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC564B618BABEA6001B9652 /* TelephoneNumberDetector.h */; };
                7CC69941191EC5F500AF2270 /* JSWebKitNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC6993F191EC5F500AF2270 /* JSWebKitNamespace.h */; };
-               7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */; };
                7CC9722E1F93E3360004D4CF /* SettingsBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC660991F93057800D500E9 /* SettingsBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7CCEBFC01DD8F6AB002C40B8 /* SVGLengthValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D531DD7B09300128552 /* SVGLengthValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7CD0BA051B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */; };
                7CC6609B1F93057900D500E9 /* SettingsBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SettingsBase.cpp; sourceTree = "<group>"; };
                7CC6993E191EC5F500AF2270 /* JSWebKitNamespace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitNamespace.cpp; sourceTree = "<group>"; };
                7CC6993F191EC5F500AF2270 /* JSWebKitNamespace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitNamespace.h; sourceTree = "<group>"; };
-               7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IDNScriptWhiteList.txt; sourceTree = "<group>"; };
                7CD0BA021B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActiveDOMCallbackMicrotask.cpp; sourceTree = "<group>"; };
                7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActiveDOMCallbackMicrotask.h; sourceTree = "<group>"; };
                7CD0E2B51F80A4820016A4CE /* AbortController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AbortController.h; sourceTree = "<group>"; };
                                65998A650E5F5FD3004E097A /* images */,
                                A1AA9AB81D23911500FEADB3 /* ContentFilterBlockedPage.html */,
                                A11E8C001B1E28BE0003A7C7 /* copyCursor.png */,
-                               7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */,
                                2D9F0E1214FF1CBF00BA0FF7 /* linearSRGB.icc */,
                                BCAD1808131C7A0D00990406 /* Localizable.strings */,
                                837A80111E1E127300026B9F /* Localizable.stringsdict */,
                                2D50A4B81CE10E0000198049 /* AttachmentPlaceholder@2x.png in Resources */,
                                A1AA9AB91D23911500FEADB3 /* ContentFilterBlockedPage.html in Resources */,
                                A11E8C051B1E28F40003A7C7 /* copyCursor.png in Resources */,
-                               7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */,
                                2D9F0E1314FF1CBF00BA0FF7 /* linearSRGB.icc in Resources */,
                                E59DD4B821098287003C8B47 /* ListButtonArrow.png in Resources */,
                                E516699120FF9918009D2C27 /* ListButtonArrow@2x.png in Resources */,
index e45fdaa..90e1cda 100644 (file)
@@ -247,6 +247,16 @@ static BOOL isLookalikeCharacter(std::optional<UChar32> previousCodePoint, UChar
     }
 }
 
+static void whiteListIDNScript(const char* scriptName)
+{
+    int32_t script = u_getPropertyValueEnum(UCHAR_SCRIPT, scriptName);
+    if (script >= 0 && script < USCRIPT_CODE_LIMIT) {
+        size_t index = script / 32;
+        uint32_t mask = 1 << (script % 32);
+        IDNScriptWhiteList[index] |= mask;
+    }
+}
+
 static BOOL readIDNScriptWhiteListFile(NSString *filename)
 {
     if (!filename)
@@ -271,12 +281,7 @@ static BOOL readIDNScriptWhiteListFile(NSString *filename)
         
         if (result == 1) {
             // Got a word, map to script code and put it into the array.
-            int32_t script = u_getPropertyValueEnum(UCHAR_SCRIPT, word);
-            if (script >= 0 && script < USCRIPT_CODE_LIMIT) {
-                size_t index = script / 32;
-                uint32_t mask = 1 << (script % 32);
-                IDNScriptWhiteList[index] |= mask;
-            }
+            whiteListIDNScript(word);
         }
     }
     fclose(file);
@@ -294,12 +299,30 @@ static BOOL allCharactersInIDNScriptWhiteList(const UChar *buffer, int32_t lengt
             if (readIDNScriptWhiteListFile([[dirs objectAtIndex:i] stringByAppendingPathComponent:@"IDNScriptWhiteList.txt"]))
                 return;
         }
-
-        // Fall back on white list inside bundle.
-        NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebCore"];
-
-        if (!readIDNScriptWhiteListFile([bundle pathForResource:@"IDNScriptWhiteList" ofType:@"txt"]))
-            CRASH();
+        const char* defaultIDNScriptWhiteList[20] = {
+            "Common",
+            "Inherited",
+            "Arabic",
+            "Armenian",
+            "Bopomofo",
+            "Canadian_Aboriginal",
+            "Devanagari",
+            "Deseret",
+            "Gujarati",
+            "Gurmukhi",
+            "Hangul",
+            "Han",
+            "Hebrew",
+            "Hiragana",
+            "Katakana_Or_Hiragana",
+            "Katakana",
+            "Latin",
+            "Tamil",
+            "Thai",
+            "Yi",
+        };
+        for (const char* scriptName : defaultIDNScriptWhiteList)
+            whiteListIDNScript(scriptName);
     });
     
     int32_t i = 0;