Bug 1068218: Don't pass lone surrogates to GetDirectionFromChar, r=ehsan
authorSimon Montagu <smontagu@smontagu.org>
Fri, 19 Sep 2014 00:18:47 -0700
changeset 206199 81a9009a5c1d6d025bed6a34f10b38adab7e1900
parent 206198 f73db3f4348155f32cdac5f4f35f75b2542975dd
child 206200 434e148f58c1932530d49ed1abe247c6f80c4e08
push id27516
push userryanvm@gmail.com
push dateFri, 19 Sep 2014 17:54:48 +0000
treeherdermozilla-central@b00bdb144e06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1068218
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1068218: Don't pass lone surrogates to GetDirectionFromChar, r=ehsan
content/base/src/DirectionalityUtils.cpp
--- a/content/base/src/DirectionalityUtils.cpp
+++ b/content/base/src/DirectionalityUtils.cpp
@@ -315,22 +315,25 @@ GetDirectionFromText(const char16_t* aTe
 
     if (NS_IS_HIGH_SURROGATE(ch) &&
         start < end &&
         NS_IS_LOW_SURROGATE(*start)) {
       ch = SURROGATE_TO_UCS4(ch, *start++);
       current++;
     }
 
-    Directionality dir = GetDirectionFromChar(ch);
-    if (dir != eDir_NotSet) {
-      if (aFirstStrong) {
-        *aFirstStrong = current;
+    // Just ignore lone surrogates
+    if (!IS_SURROGATE(ch)) {
+      Directionality dir = GetDirectionFromChar(ch);
+      if (dir != eDir_NotSet) {
+        if (aFirstStrong) {
+          *aFirstStrong = current;
+        }
+        return dir;
       }
-      return dir;
     }
   }
 
   if (aFirstStrong) {
     *aFirstStrong = UINT32_MAX;
   }
   return eDir_NotSet;
 }