Bug 1325995 - Disallow backslash in WebGL 1. - r=daoshengmu draft
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 03 Jan 2017 02:05:43 -0800
changeset 455259 23b57b4aa508acce65fa09385dfad71aa37ef999
parent 455258 a61b01b7f3ccb5465299e573f32d6206f2bae527
child 540933 93bf0bf58379f0042b5729cc5f97f3f7417e7391
push id40178
push userbmo:jgilbert@mozilla.com
push dateTue, 03 Jan 2017 10:08:32 +0000
reviewersdaoshengmu
bugs1325995
milestone53.0a1
Bug 1325995 - Disallow backslash in WebGL 1. - r=daoshengmu MozReview-Commit-ID: IrBZYnPVLU
dom/canvas/WebGLValidateStrings.cpp
--- a/dom/canvas/WebGLValidateStrings.cpp
+++ b/dom/canvas/WebGLValidateStrings.cpp
@@ -171,20 +171,28 @@ IsValidGLSLPreprocChar(char16_t c)
 ////
 
 bool
 ValidateGLSLPreprocString(WebGLContext* webgl, const char* funcName,
                           const nsAString& string)
 {
     for (size_t i = 0; i < string.Length(); ++i) {
         const auto& cur = string[i];
+
         if (!IsValidGLSLPreprocChar(cur)) {
-           webgl->ErrorInvalidValue("%s: String contains the illegal character 0x%x.",
-                                    funcName, cur);
-           return false;
+            webgl->ErrorInvalidValue("%s: String contains the illegal character 0x%x.",
+                                     funcName, cur);
+            return false;
+        }
+
+        if (cur == '\\' && !webgl->IsWebGL2()) {
+            // Todo: Backslash is technically still invalid in WebGLSL 1 under even under
+            // WebGL 2.
+            webgl->ErrorInvalidValue("%s: Backslash is not valid in WebGL 1.", funcName);
+            return false;
         }
     }
 
     return true;
 }
 
 bool
 ValidateGLSLVariableName(const nsAString& name, WebGLContext* webgl, const char* funcName)