Bugfix uriEscapeTable generate.
authorRam Kumar Rengaswamy <ramr@beeswax.com>
Sat, 14 Feb 2015 20:45:07 +0000 (15:45 -0500)
committerSara Golemon <sgolemon@fb.com>
Thu, 5 Mar 2015 18:22:52 +0000 (10:22 -0800)
Summary:
generate_escape_tables.py uses python range function which does not include the end of the range.

Closes #131

Test Plan: See attached test case.

Reviewed By: njormrod@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1871692

Signature: t1:1871692:1425076132:2438ab7554fe87bdef17c82ff27713811a270d7c

folly/build/generate_escape_tables.py
folly/test/StringTest.cpp

index 03df62a35181c8796ff755ed653ac8bb9fc5f1d6..8ca67bd20e102ae7959d44f2bf76f084865972da 100755 (executable)
@@ -79,9 +79,9 @@ def generate(f):
     # 4 = always percent-encode
     f.write("extern const unsigned char uriEscapeTable[] = {")
     passthrough = (
-        list(range(ord('0'), ord('9'))) +
-        list(range(ord('A'), ord('Z'))) +
-        list(range(ord('a'), ord('z'))) +
+        list(map(ord, '0123456789')) +
+        list(map(ord, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')) +
+        list(map(ord, 'abcdefghijklmnopqrstuvwxyz')) +
         list(map(ord, '-_.~')))
     for i in range(0, 256):
         if i % 16 == 0:
index f23009021989d43cc0cd9ccc8f37a4b7c3f34c38..fa0ee55907fe306acf118b6344d65547e05b3693 100644 (file)
@@ -220,6 +220,11 @@ TEST(Escape, uriEscape) {
                                                         UriEscapeMode::PATH));
   EXPECT_EQ("hello%2c+%2fworld", uriEscape<std::string>("hello, /world",
                                                         UriEscapeMode::QUERY));
+  EXPECT_EQ(
+    "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.~",
+    uriEscape<std::string>(
+      "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.~")
+  );
 }
 
 TEST(Escape, uriUnescape) {