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
# 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:
UriEscapeMode::PATH));
EXPECT_EQ("hello%2c+%2fworld", uriEscape<std::string>("hello, /world",
UriEscapeMode::QUERY));
+ EXPECT_EQ(
+ "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.~",
+ uriEscape<std::string>(
+ "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.~")
+ );
}
TEST(Escape, uriUnescape) {