Bug 1068218 - Don't pass lone surrogates to GetDirectionFromChar. r=ehsan, a=abillings
authorSimon Montagu <smontagu@smontagu.org>
Fri, 19 Sep 2014 00:18:47 -0700
changeset 216806 389dd23d771c
parent 216805 f14c89b414b6
child 216807 ae87b325401d
push id3921
push userryanvm@gmail.com
push date2014-09-22 15:03 +0000
treeherdermozilla-beta@f8eec8fe1b2b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, abillings
bugs1068218
milestone33.0
Bug 1068218 - Don't pass lone surrogates to GetDirectionFromChar. r=ehsan, a=abillings
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;
 }