END_TEST START_TEST(UrlDecodeShouldSkipBadEscapes) { String str = String_FromC("This%is a%%aa%test.%f"); const char *expectedResult = "This%is a%\xAA%test.%f"; ASSERT_STRING(String_UrlDecode(str), expectedResult, StrLen(expectedResult)); str = String_FromC("This%is a%%aa%test.%"); expectedResult = "This%is a%\xAA%test.%"; ASSERT_STRING(String_UrlDecode(str), expectedResult, StrLen(expectedResult)); }
END_TEST START_TEST(UrlDecodeShouldDecodeUppercaseNonAsciiCharacters) { String str = String_FromC("This%00is%0D%0Aa%7F%C2%A0test."); ASSERT_STRING(String_UrlDecode(str), "This\0is\r\na\x7F\xC2\xA0test.", 18); }
END_TEST START_TEST(UrlDecodeShouldDecodeLowercaseNonAsciiCharacters) { String str = String_FromC("This%00is%0d%0aa%7f%c2%a0test."); ASSERT_STRING(String_UrlDecode(str), "This\0is\r\na\x7F\xC2\xA0test.", 18); }
END_TEST START_TEST(UrlDecodeShouldDecodeDangerousCharactersFromEscapes) { String str = String_FromC("%5B%28%21%2AThis%20%27%3Bis%20%3A%40%26%3D%20a%20%2B%25%24test%2C%2F%3F%23%29%5D"); const char *expectedResult = "[(!*This ';is :@&= a +%$test,/?#)]"; ASSERT_STRING(String_UrlDecode(str), expectedResult, StrLen(expectedResult)); }
END_TEST START_TEST(UrlQueryEncodeShouldIgnoreSafePunctuation) { String str = String_FromC("\"-.<>\\^_`{|}~Pack my box with five dozen liquor jugs."); const char *expectedResult = "\"-.<>\\^_`{|}~Pack%20my%20box%20with%20five%20dozen%20liquor%20jugs."; ASSERT_STRING(String_UrlQueryEncode(str), expectedResult, StrLen(expectedResult)); }
END_TEST START_TEST(HtmlDecodeShouldSkipBadInput) { ASSERT_STRING(String_HtmlDecode(String_FromC("&frog;This is a test.")), "&frog;This is a test.", 15 + 6); ASSERT_STRING(String_HtmlDecode(String_FromC("&#;This is a test.")), "&#;This is a test.", 15 + 3); ASSERT_STRING(String_HtmlDecode(String_FromC("f;This is a test.")), "f;This is a test.", 15 + 6); ASSERT_STRING(String_HtmlDecode(String_FromC("&#frog;This is a test.")), "&#frog;This is a test.", 15 + 7); ASSERT_STRING(String_HtmlDecode(String_FromC("&#x;This is a test.")), "&#x;This is a test.", 15 + 4); ASSERT_STRING(String_HtmlDecode(String_FromC("&#xz;This is a test.")), "&#xz;This is a test.", 15 + 5); ASSERT_STRING(String_HtmlDecode(String_FromC("z;This is a test.")), "z;This is a test.", 15 + 7); }
static SmileObject ParseOneConstantValue(CommandLineArgs options, const char *text) { String string; Lexer lexer; Parser parser; SmileObject result; string = String_FromC(text); lexer = Lexer_Create(string, 0, String_Length(string), _commandLineArgument, 1, 1); parser = Parser_Create(); result = Parser_ParseConstant(parser, lexer, ParseScope_CreateRoot()); if (parser->firstMessage != NULL) { Bool hasErrors = PrintParseMessages(options, parser); if (hasErrors) return NullObject; } return result; }
END_TEST START_TEST(HtmlDecodeShouldDecodeNumericLatin1EntitiesToUtf8) { ASSERT_STRING(String_HtmlDecode(String_FromC(" This Áis ½ a átest.ÿÞ")), "\xC2\xA0This \xC3\x81is \xC2\xBD a \xC3\xA1test.\xC3\xBF\xC3\x9E", 28); }
END_TEST START_TEST(HtmlDecodeShouldDecodeNamedNonLatin1EntitiesToUtf8) { ASSERT_STRING(String_HtmlDecode(String_FromC("ΣThis αis Ÿ a —test.∀♥")), "\xCE\xA3This \xCE\xB1is \xC5\xB8 a \xE2\x80\x94test.\xE2\x88\x80\xE2\x99\xA5", 31); }
END_TEST START_TEST(HtmlDecodeShouldDecodeNamedLatin1EntitiesToUtf8) { ASSERT_STRING(String_HtmlDecode(String_FromC(" This Áis ½ a átest.ÿÞ")), "\xC2\xA0This \xC3\x81is \xC2\xBD a \xC3\xA1test.\xC3\xBF\xC3\x9E", 28); }
END_TEST START_TEST(HtmlDecodeShouldDecodeTheAsciiNamedEntities) { ASSERT_STRING(String_HtmlDecode(String_FromC("<This 'is & a "test.">")), "<This 'is & a \"test.\">", 22); }
END_TEST START_TEST(UnencodedStringsShouldHtmlDecodeToUnencodedStrings) { ASSERT_STRING(String_HtmlDecode(String_FromC("This is a test.")), "This is a test.", 15); }
END_TEST START_TEST(HtmlDecodeShouldDecodeLowercaseHexadecimalNonLatin1EntitiesToUtf8) { ASSERT_STRING(String_HtmlDecode(String_FromC("ΣThis αis Ÿ a —test.∀♥")), "\xCE\xA3This \xCE\xB1is \xC5\xB8 a \xE2\x80\x94test.\xE2\x88\x80\xE2\x99\xA5", 31); }
END_TEST START_TEST(HtmlDecodeShouldDecodeHexadecimalCornerCases) { ASSERT_STRING(String_HtmlDecode(String_FromC("�This is 
 a Atest. ")), "\0This \1is \n a Atest.\x1B ", 22); }
END_TEST START_TEST(HtmlDecodeShouldDecodeDecimalCornerCases) { ASSERT_STRING(String_HtmlDecode(String_FromC("�This is a Atest. ")), "\0This \1is \n a Atest.\x1B ", 22); }
static Lexer Setup(const char *string) { return SetupString(String_FromC(string)); }
END_TEST START_TEST(HtmlDecodeShouldDecodeDecimalNonLatin1EntitiesToUtf8) { ASSERT_STRING(String_HtmlDecode(String_FromC("ΣThis αis Ÿ a —test.∀♥")), "\xCE\xA3This \xCE\xB1is \xC5\xB8 a \xE2\x80\x94test.\xE2\x88\x80\xE2\x99\xA5", 31); }