Commit 47e8b72f authored by Ram Kumar Rengaswamy's avatar Ram Kumar Rengaswamy Committed by Sara Golemon

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
parent 5c483dd4
...@@ -79,9 +79,9 @@ def generate(f): ...@@ -79,9 +79,9 @@ def generate(f):
# 4 = always percent-encode # 4 = always percent-encode
f.write("extern const unsigned char uriEscapeTable[] = {") f.write("extern const unsigned char uriEscapeTable[] = {")
passthrough = ( passthrough = (
list(range(ord('0'), ord('9'))) + list(map(ord, '0123456789')) +
list(range(ord('A'), ord('Z'))) + list(map(ord, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')) +
list(range(ord('a'), ord('z'))) + list(map(ord, 'abcdefghijklmnopqrstuvwxyz')) +
list(map(ord, '-_.~'))) list(map(ord, '-_.~')))
for i in range(0, 256): for i in range(0, 256):
if i % 16 == 0: if i % 16 == 0:
......
...@@ -220,6 +220,11 @@ TEST(Escape, uriEscape) { ...@@ -220,6 +220,11 @@ TEST(Escape, uriEscape) {
UriEscapeMode::PATH)); UriEscapeMode::PATH));
EXPECT_EQ("hello%2c+%2fworld", uriEscape<std::string>("hello, /world", EXPECT_EQ("hello%2c+%2fworld", uriEscape<std::string>("hello, /world",
UriEscapeMode::QUERY)); UriEscapeMode::QUERY));
EXPECT_EQ(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.~",
uriEscape<std::string>(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.~")
);
} }
TEST(Escape, uriUnescape) { TEST(Escape, uriUnescape) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment