diff options
author | Jörg Frings-Fürst <debian@jff-webhsoting.net> | 2021-04-26 20:34:38 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhsoting.net> | 2021-04-26 20:34:38 +0200 |
commit | 57be5b9e80075d32249105407879dd1d2bac460b (patch) | |
tree | f161e88bc941e1c861b1dd1a34a332f8cdc53f7a /test | |
parent | cf9293531802f491b4b145d98a4900e72a7d105b (diff) | |
parent | 7d4216c07bd36b69ae7f5eabb7b4d6b59166a508 (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'test')
-rw-r--r-- | test/MemoryManagerSuite.cpp | 4 | ||||
-rw-r--r-- | test/test.cpp | 57 |
2 files changed, 60 insertions, 1 deletions
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 <gtest/gtest.h> #include <uriparser/Uri.h> + +// 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; |