From cb39f81ea1957f5fdd9b5b67d7d326091efd3d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 26 Apr 2021 20:34:11 +0200 Subject: New upstream version 0.9.5 --- test/MemoryManagerSuite.cpp | 4 ++++ test/test.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/MemoryManagerSuite.cpp b/test/MemoryManagerSuite.cpp index 4cda664..a828d76 100644 --- a/test/MemoryManagerSuite.cpp +++ b/test/MemoryManagerSuite.cpp @@ -27,7 +27,11 @@ #include #include + +// For defaultMemoryManager +extern "C" { #include "../src/UriMemory.h" +} namespace { diff --git a/test/test.cpp b/test/test.cpp index 9a189f9..4b156a4 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -311,7 +311,7 @@ TEST(UriSuite, TestUri) { ASSERT_TRUE(0 == uriParseUriA(&stateA, "//user:pass@localhost/one/two/three")); uriFreeUriMembersA(&uriA); - // ANSI and Unicode + // Both narrow and wide string version ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://www.example.com/")); uriFreeUriMembersA(&uriA); ASSERT_TRUE(0 == uriParseUriW(&stateW, L"http://www.example.com/")); @@ -1098,6 +1098,19 @@ TEST(UriSuite, TestAddBase) { // Bug related to absolutePath flag set despite presence of host ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/", L"http://a/")); ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/g/", L"http://a/g/")); + + // GitHub issue #92 + EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/../d;p?q", L"../..", L"http://a/")); + EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/../d;p?q", L"../../", L"http://a/")); + + EXPECT_TRUE(testAddBaseHelper(L"http://a/b/../c/d;p?q", L"../..", L"http://a/")); + EXPECT_TRUE(testAddBaseHelper(L"http://a/b/../c/d;p?q", L"../../", L"http://a/")); + + EXPECT_TRUE(testAddBaseHelper(L"http://a/../b/c/d;p?q", L"../..", L"http://a/")); + EXPECT_TRUE(testAddBaseHelper(L"http://a/../b/c/d;p?q", L"../../", L"http://a/")); + + EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../..", L"http://a/")); + EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../../", L"http://a/")); } namespace { @@ -1477,6 +1490,48 @@ TEST(UriSuite, TestNormalizeSyntaxComponents) { URI_NORMALIZE_FRAGMENT)); } +TEST(UriSuite, TestNormalizeSyntaxPath) { + // These are from GitHub issue #92 + EXPECT_TRUE(testNormalizeSyntaxHelper( + L"http://a/b/c/../../..", + L"http://a/", + URI_NORMALIZE_PATH)); + EXPECT_TRUE(testNormalizeSyntaxHelper( + L"http://a/b/../c/../..", + L"http://a/", + URI_NORMALIZE_PATH)); + EXPECT_TRUE(testNormalizeSyntaxHelper( + L"http://a/b/c/../../..", + L"http://a/", + URI_NORMALIZE_PATH)); + + // .. and these are related + EXPECT_TRUE(testNormalizeSyntaxHelper( + L"http://a/..", + L"http://a/", + URI_NORMALIZE_PATH)); + EXPECT_TRUE(testNormalizeSyntaxHelper( + L"/..", + L"/", + URI_NORMALIZE_PATH)); + EXPECT_TRUE(testNormalizeSyntaxHelper( + L"http://a/..///", + L"http://a///", + URI_NORMALIZE_PATH)); + EXPECT_TRUE(testNormalizeSyntaxHelper( + L"http://a/..///..", + L"http://a//", + URI_NORMALIZE_PATH)); + EXPECT_TRUE(testNormalizeSyntaxHelper( + L"a/b/c/../../..", + L"", + URI_NORMALIZE_PATH)); + EXPECT_TRUE(testNormalizeSyntaxHelper( + L"a/b/../../c/..", + L"", + URI_NORMALIZE_PATH)); +} + TEST(UriSuite, TestNormalizeCrashBug20080224) { UriParserStateW stateW; int res; -- cgit v1.2.3