예제 #1
0
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));
}
예제 #2
0
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);
}
예제 #3
0
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);
}
예제 #4
0
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));
}
예제 #5
0
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));
}
예제 #6
0
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("&#15f;This is a test.")), "&#15f;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("&#x15z;This is a test.")), "&#x15z;This is a test.", 15 + 7);
}
예제 #7
0
파일: main.c 프로젝트: seanofw/smile
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;
}
예제 #8
0
END_TEST

START_TEST(HtmlDecodeShouldDecodeNumericLatin1EntitiesToUtf8)
{
    ASSERT_STRING(String_HtmlDecode(String_FromC("&#160;This &#193;is &#189; a &#225;test.&#255;&#222;")), "\xC2\xA0This \xC3\x81is \xC2\xBD a \xC3\xA1test.\xC3\xBF\xC3\x9E", 28);
}
예제 #9
0
END_TEST

START_TEST(HtmlDecodeShouldDecodeNamedNonLatin1EntitiesToUtf8)
{
    ASSERT_STRING(String_HtmlDecode(String_FromC("&Sigma;This &alpha;is &Yuml; a &mdash;test.&forall;&hearts;")), "\xCE\xA3This \xCE\xB1is \xC5\xB8 a \xE2\x80\x94test.\xE2\x88\x80\xE2\x99\xA5", 31);
}
예제 #10
0
END_TEST

START_TEST(HtmlDecodeShouldDecodeNamedLatin1EntitiesToUtf8)
{
    ASSERT_STRING(String_HtmlDecode(String_FromC("&nbsp;This &Aacute;is &frac12; a &aacute;test.&yuml;&THORN;")), "\xC2\xA0This \xC3\x81is \xC2\xBD a \xC3\xA1test.\xC3\xBF\xC3\x9E", 28);
}
예제 #11
0
END_TEST

START_TEST(HtmlDecodeShouldDecodeTheAsciiNamedEntities)
{
    ASSERT_STRING(String_HtmlDecode(String_FromC("&lt;This &apos;is &amp; a &quot;test.&quot;&gt;")), "<This 'is & a \"test.\">", 22);
}
예제 #12
0
END_TEST

START_TEST(UnencodedStringsShouldHtmlDecodeToUnencodedStrings)
{
    ASSERT_STRING(String_HtmlDecode(String_FromC("This is a test.")), "This is a test.", 15);
}
예제 #13
0
END_TEST

START_TEST(HtmlDecodeShouldDecodeLowercaseHexadecimalNonLatin1EntitiesToUtf8)
{
    ASSERT_STRING(String_HtmlDecode(String_FromC("&#x3a3;This &#x3b1;is &#x178; a &#x2014;test.&#x2200;&#x2665;")), "\xCE\xA3This \xCE\xB1is \xC5\xB8 a \xE2\x80\x94test.\xE2\x88\x80\xE2\x99\xA5", 31);
}
예제 #14
0
END_TEST

START_TEST(HtmlDecodeShouldDecodeHexadecimalCornerCases)
{
    ASSERT_STRING(String_HtmlDecode(String_FromC("&#x0;This &#x1;is &#xA; a &#x41;test.&#x1B;&#x20;")), "\0This \1is \n a Atest.\x1B ", 22);
}
예제 #15
0
END_TEST

START_TEST(HtmlDecodeShouldDecodeDecimalCornerCases)
{
    ASSERT_STRING(String_HtmlDecode(String_FromC("&#0;This &#1;is &#10; a &#65;test.&#27;&#32;")), "\0This \1is \n a Atest.\x1B ", 22);
}
예제 #16
0
static Lexer Setup(const char *string)
{
	return SetupString(String_FromC(string));
}
예제 #17
0
END_TEST

START_TEST(HtmlDecodeShouldDecodeDecimalNonLatin1EntitiesToUtf8)
{
    ASSERT_STRING(String_HtmlDecode(String_FromC("&#931;This &#945;is &#376; a &#8212;test.&#8704;&#9829;")), "\xCE\xA3This \xCE\xB1is \xC5\xB8 a \xE2\x80\x94test.\xE2\x88\x80\xE2\x99\xA5", 31);
}