From 47e8b72f38b34ed2720ccbd52a8ed097f8653560 Mon Sep 17 00:00:00 2001 From: Ram Kumar Rengaswamy Date: Sat, 14 Feb 2015 15:45:07 -0500 Subject: [PATCH] Bugfix uriEscapeTable generate. 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 | 6 +++--- folly/test/StringTest.cpp | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/folly/build/generate_escape_tables.py b/folly/build/generate_escape_tables.py index 03df62a3..8ca67bd2 100755 --- a/folly/build/generate_escape_tables.py +++ b/folly/build/generate_escape_tables.py @@ -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: diff --git a/folly/test/StringTest.cpp b/folly/test/StringTest.cpp index f2300902..fa0ee559 100644 --- a/folly/test/StringTest.cpp +++ b/folly/test/StringTest.cpp @@ -220,6 +220,11 @@ TEST(Escape, uriEscape) { UriEscapeMode::PATH)); EXPECT_EQ("hello%2c+%2fworld", uriEscape("hello, /world", UriEscapeMode::QUERY)); + EXPECT_EQ( + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.~", + uriEscape( + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.~") + ); } TEST(Escape, uriUnescape) { -- 2.34.1