Bug 1325995 - Disallow backslash in WebGL 1. - r=daoshengmu
MozReview-Commit-ID: IrBZYnPVLU
--- 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)