Bug 1318299 - Replace string literals containing escaped characters with raw string literals in security/manager. draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Thu, 17 Nov 2016 13:42:38 +0200
changeset 441032 72cd9a36536edcb6e1dff3e74dfcafc33acc10cb
parent 441031 26499036a743de8f04c24036200fee69cad55dde
child 441033 f66c883fc48df3f0cb529ddda74a6a220bd50ccb
push id36337
push userbmo:bpostelnicu@mozilla.com
push dateFri, 18 Nov 2016 08:49:28 +0000
bugs1318299
milestone53.0a1
Bug 1318299 - Replace string literals containing escaped characters with raw string literals in security/manager. MozReview-Commit-ID: Al4QjodbJ2S
security/manager/ssl/tests/gtest/STSParserTest.cpp
--- a/security/manager/ssl/tests/gtest/STSParserTest.cpp
+++ b/security/manager/ssl/tests/gtest/STSParserTest.cpp
@@ -64,19 +64,19 @@ TEST(psm_STSParser, Test)
     // *** parsing tests
     printf("*** Attempting to parse valid STS headers ...\n");
 
     // SHOULD SUCCEED:
     TestSuccess("max-age=100", false, 100, false, sss);
     TestSuccess("max-age  =100", false, 100, false, sss);
     TestSuccess(" max-age=100", false, 100, false, sss);
     TestSuccess("max-age = 100 ", false, 100, false, sss);
-    TestSuccess("max-age = \"100\" ", false, 100, false, sss);
-    TestSuccess("max-age=\"100\"", false, 100, false, sss);
-    TestSuccess(" max-age =\"100\" ", false, 100, false, sss);
+    TestSuccess(R"(max-age = "100" )", false, 100, false, sss);
+    TestSuccess(R"(max-age="100")", false, 100, false, sss);
+    TestSuccess(R"( max-age ="100" )", false, 100, false, sss);
     TestSuccess("\tmax-age\t=\t\"100\"\t", false, 100, false, sss);
     TestSuccess("max-age  =       100             ", false, 100, false, sss);
 
     TestSuccess("maX-aGe=100", false, 100, false, sss);
     TestSuccess("MAX-age  =100", false, 100, false, sss);
     TestSuccess("max-AGE=100", false, 100, false, sss);
     TestSuccess("Max-Age = 100 ", false, 100, false, sss);
     TestSuccess("MAX-AGE = 100 ", false, 100, false, sss);
@@ -99,17 +99,17 @@ TEST(psm_STSParser, Test)
 
     // these are weird tests, but are testing that some extended syntax is
     // still allowed (but it is ignored)
     TestSuccess("max-age=100 ; includesubdomainsSomeStuff",
                 true, 100, false, sss);
     TestSuccess("\r\n\t\t    \tcompletelyUnrelated = foobar; max-age= 34520103"
                 "\t \t; alsoUnrelated;asIsThis;\tincludeSubdomains\t\t \t",
                 true, 34520103, true, sss);
-    TestSuccess("max-age=100; unrelated=\"quoted \\\"thingy\\\"\"",
+    TestSuccess(R"(max-age=100; unrelated="quoted \"thingy\"")",
                 true, 100, false, sss);
 
     // SHOULD FAIL:
     printf("* Attempting to parse invalid STS headers (should not parse)...\n");
     // invalid max-ages
     TestFailure("max-age", sss);
     TestFailure("max-age ", sss);
     TestFailure("max-age=p", sss);
@@ -120,17 +120,17 @@ TEST(psm_STSParser, Test)
 
     // invalid headers
     TestFailure("foobar", sss);
     TestFailure("maxage=100", sss);
     TestFailure("maxa-ge=100", sss);
     TestFailure("max-ag=100", sss);
     TestFailure("includesubdomains", sss);
     TestFailure(";", sss);
-    TestFailure("max-age=\"100", sss);
+    TestFailure(R"(max-age="100)", sss);
     // The max-age directive here doesn't conform to the spec, so it MUST
     // be ignored. Consequently, the REQUIRED max-age directive is not
     // present in this header, and so it is invalid.
     TestFailure("max-age=100, max-age=200; includeSubdomains", sss);
     TestFailure("max-age=100 includesubdomains", sss);
     TestFailure("max-age=100 bar foo", sss);
     TestFailure("max-age=100randomstuffhere", sss);
     // All directives MUST appear only once in an STS header field.