Title: [282497] releases/WebKitGTK/webkit-2.32
Revision
282497
Author
[email protected]
Date
2021-09-16 01:00:13 -0700 (Thu, 16 Sep 2021)

Log Message

Merge r275554 - Add U+0581 and U+0585 to list of Armenian characters that look like Latin characters
https://bugs.webkit.org/show_bug.cgi?id=224219
Source/WTF:

<rdar://75896365>

Patch by Alex Christensen <[email protected]> on 2021-04-06
Reviewed by Brent Fulgham.

These code points are allowed in the context of other Armenian code points and punctuation, but not other script code points.
This was already implemented for the others, but I consolidated the list to one location to avoid having two locations for the list.

* wtf/URLHelpers.cpp:
(WTF::URLHelpers::isArmenianLookalikeCharacter):
(WTF::URLHelpers::isArmenianLookalikeSequence):
(WTF::URLHelpers::isLookalikeCharacter):

Tools:

Patch by Alex Christensen <[email protected]> on 2021-04-06
Reviewed by Brent Fulgham.

* TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.32/Source/WTF/ChangeLog (282496 => 282497)


--- releases/WebKitGTK/webkit-2.32/Source/WTF/ChangeLog	2021-09-16 08:00:07 UTC (rev 282496)
+++ releases/WebKitGTK/webkit-2.32/Source/WTF/ChangeLog	2021-09-16 08:00:13 UTC (rev 282497)
@@ -1,3 +1,19 @@
+2021-04-06  Alex Christensen  <[email protected]>
+
+        Add U+0581 and U+0585 to list of Armenian characters that look like Latin characters
+        https://bugs.webkit.org/show_bug.cgi?id=224219
+        <rdar://75896365>
+
+        Reviewed by Brent Fulgham.
+
+        These code points are allowed in the context of other Armenian code points and punctuation, but not other script code points.
+        This was already implemented for the others, but I consolidated the list to one location to avoid having two locations for the list.
+
+        * wtf/URLHelpers.cpp:
+        (WTF::URLHelpers::isArmenianLookalikeCharacter):
+        (WTF::URLHelpers::isArmenianLookalikeSequence):
+        (WTF::URLHelpers::isLookalikeCharacter):
+
 2021-08-21  Sihui Liu  <[email protected]>
 
         IndexedDB: crash when triggering IDBOpenRequest completion back on a worker thread

Modified: releases/WebKitGTK/webkit-2.32/Source/WTF/wtf/URLHelpers.cpp (282496 => 282497)


--- releases/WebKitGTK/webkit-2.32/Source/WTF/wtf/URLHelpers.cpp	2021-09-16 08:00:07 UTC (rev 282496)
+++ releases/WebKitGTK/webkit-2.32/Source/WTF/wtf/URLHelpers.cpp	2021-09-16 08:00:13 UTC (rev 282497)
@@ -69,7 +69,19 @@
 
 static bool isArmenianLookalikeCharacter(UChar32 codePoint)
 {
-    return codePoint == 0x0548 || codePoint == 0x054D || codePoint == 0x0578 || codePoint == 0x057D;
+    switch (codePoint) {
+    case 0x0548: /* ARMENIAN CAPITAL LETTER VO */
+    case 0x054D: /* ARMENIAN CAPITAL LETTER SEH */
+    case 0x0551: /* ARMENIAN CAPITAL LETTER CO */
+    case 0x0555: /* ARMENIAN CAPITAL LETTER OH */
+    case 0x0578: /* ARMENIAN SMALL LETTER VO */
+    case 0x057D: /* ARMENIAN SMALL LETTER SEH */
+    case 0x0581: /* ARMENIAN SMALL LETTER CO */
+    case 0x0585: /* ARMENIAN SMALL LETTER OH */
+        return true;
+    default:
+        return false;
+    }
 }
 
 static bool isArmenianScriptCharacter(UChar32 codePoint)
@@ -106,8 +118,20 @@
     }
 }
 
-static bool isLookalikeCharacter(const Optional<UChar32>& previousCodePoint, UChar32 charCode)
+static bool isArmenianLookalikeSequence(const Optional<UChar32>& previousCodePoint, UChar32 codePoint)
 {
+    if (!previousCodePoint || *previousCodePoint == '/')
+        return false;
+
+    auto isArmenianLookalikePair = [] (UChar first, UChar second) {
+        return isArmenianLookalikeCharacter(first) && !(isArmenianScriptCharacter(second) || isASCIIDigitOrValidHostCharacter(second));
+    };
+    return isArmenianLookalikePair(codePoint, *previousCodePoint)
+        || isArmenianLookalikePair(*previousCodePoint, codePoint);
+}
+
+static bool isLookalikeCharacter(const Optional<UChar32>& previousCodePoint, UChar32 codePoint)
+{
     // This function treats the following as unsafe, lookalike characters:
     // any non-printable character, any character considered as whitespace,
     // any ignorable character, and emoji characters related to locks.
@@ -119,10 +143,10 @@
     // slashes into an ASCII solidus. But one of the two callers uses this
     // on characters that have not been processed by ICU, so they are needed here.
     
-    if (!u_isprint(charCode) || u_isUWhiteSpace(charCode) || u_hasBinaryProperty(charCode, UCHAR_DEFAULT_IGNORABLE_CODE_POINT))
+    if (!u_isprint(codePoint) || u_isUWhiteSpace(codePoint) || u_hasBinaryProperty(codePoint, UCHAR_DEFAULT_IGNORABLE_CODE_POINT))
         return true;
     
-    switch (charCode) {
+    switch (codePoint) {
     case 0x00BC: /* VULGAR FRACTION ONE QUARTER */
     case 0x00BD: /* VULGAR FRACTION ONE HALF */
     case 0x00BE: /* VULGAR FRACTION THREE QUARTERS */
@@ -250,19 +274,10 @@
         return previousCodePoint == 0x0237 /* LATIN SMALL LETTER DOTLESS J */
             || previousCodePoint == 0x0131 /* LATIN SMALL LETTER DOTLESS I */
             || previousCodePoint == 0x05D5; /* HEBREW LETTER VAV */
-    case 0x0548: /* ARMENIAN CAPITAL LETTER VO */
-    case 0x054D: /* ARMENIAN CAPITAL LETTER SEH */
-    case 0x0578: /* ARMENIAN SMALL LETTER VO */
-    case 0x057D: /* ARMENIAN SMALL LETTER SEH */
-        return previousCodePoint
-            && !isASCIIDigitOrValidHostCharacter(previousCodePoint.value())
-            && !isArmenianScriptCharacter(previousCodePoint.value());
     case '.':
         return false;
     default:
-        return previousCodePoint
-            && isArmenianLookalikeCharacter(previousCodePoint.value())
-            && !(isArmenianScriptCharacter(charCode) || isASCIIDigitOrValidHostCharacter(charCode));
+        return isArmenianLookalikeSequence(previousCodePoint, codePoint);
     }
 }
 

Modified: releases/WebKitGTK/webkit-2.32/Tools/ChangeLog (282496 => 282497)


--- releases/WebKitGTK/webkit-2.32/Tools/ChangeLog	2021-09-16 08:00:07 UTC (rev 282496)
+++ releases/WebKitGTK/webkit-2.32/Tools/ChangeLog	2021-09-16 08:00:13 UTC (rev 282497)
@@ -1,3 +1,13 @@
+2021-04-06  Alex Christensen  <[email protected]>
+
+        Add U+0581 and U+0585 to list of Armenian characters that look like Latin characters
+        https://bugs.webkit.org/show_bug.cgi?id=224219
+
+        Reviewed by Brent Fulgham.
+
+        * TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm:
+        (TestWebKitAPI::TEST):
+
 2021-07-29  Michael Catanzaro  <[email protected]>
 
         [WPE][GTK] .asc file extension is appended to filename of text/plain downloads

Modified: releases/WebKitGTK/webkit-2.32/Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm (282496 => 282497)


--- releases/WebKitGTK/webkit-2.32/Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm	2021-09-16 08:00:07 UTC (rev 282496)
+++ releases/WebKitGTK/webkit-2.32/Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm	2021-09-16 08:00:13 UTC (rev 282497)
@@ -115,6 +115,10 @@
         "xn--fja", // U+01C0
         "xn--koa", // U+0274
         "xn--tma", // U+0237
+        "xn--o-pdc", // U+0585 'o'
+        "xn--o-qdc", // 'o' U+0585
+        "xn--g-hdc", // U+0581 'g'
+        "xn--g-idc", // 'g' U+0581
     };
     for (const String& host : punycodedSpoofHosts) {
         auto url = "" host, "/").utf8();
@@ -130,10 +134,14 @@
     EXPECT_STREQ("https://\u0573-1-\u0574\u0578.\u0570\u0561\u0575", userVisibleString(literalURL("https://\u0573-1-\u0574\u0578.\u0570\u0561\u0575")));
     EXPECT_STREQ("https://2\u0573_\u0574\u0578.\u0570\u0561\u0575", userVisibleString(literalURL("https://2\u0573_\u0574\u0578.\u0570\u0561\u0575")));
     EXPECT_STREQ("https://\u0573_\u0574\u05783.\u0570\u0561\u0575", userVisibleString(literalURL("https://\u0573_\u0574\u05783.\u0570\u0561\u0575")));
-    EXPECT_STREQ("https://got\u0551\u0535\u0543.com", userVisibleString(literalURL("https://got\u0551\u0535\u0543.com")));
+    EXPECT_STREQ("https://got%D5%91\u0535\u0543.com", userVisibleString(literalURL("https://got\u0551\u0535\u0543.com")));
     EXPECT_STREQ("https://\u0551\u0535\u0543fans.net", userVisibleString(literalURL("https://\u0551\u0535\u0543fans.net")));
     EXPECT_STREQ("https://\u0551\u0535or\u0575\u0543.biz", userVisibleString(literalURL("https://\u0551\u0535or\u0575\u0543.biz")));
     EXPECT_STREQ("https://\u0551\u0535and!$^&*()-~+={}or<>,.?\u0575\u0543.biz", userVisibleString(literalURL("https://\u0551\u0535and!$^&*()-~+={}or<>,.?\u0575\u0543.biz")));
+    EXPECT_STREQ("https://\u0551%67/", userVisibleString(literalURL("https://\u0551g/")));
+    EXPECT_STREQ("https://\u0581%67/", userVisibleString(literalURL("https://\u0581g/")));
+    EXPECT_STREQ("https://o%D5%95%2F", userVisibleString(literalURL("https://o\u0555/")));
+    EXPECT_STREQ("https://o%D6%85%2F", userVisibleString(literalURL("https://o\u0585/")));
 }
 
 TEST(WTF_URLExtras, URLExtras_DivisionSign)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to