summaryrefslogtreecommitdiff
path: root/test/test.cpp
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhsoting.net>2021-05-17 18:45:48 +0200
committerJörg Frings-Fürst <debian@jff-webhsoting.net>2021-05-17 18:45:48 +0200
commite88cb800c1d2f1d106238cfdcf0a8db5519cc5d5 (patch)
tree8c6f15949ac5d74a6b8a7de0d9cede924ff7b5c5 /test/test.cpp
parentcbca5053aa041134ac8b859aa3b3ea84f5c07328 (diff)
parent02179e607b61eccf0fd6580c67f467f6d669005c (diff)
Merge branch 'release/debian/0.9.5+dfsg-1'debian/0.9.5+dfsg-1
Diffstat (limited to 'test/test.cpp')
-rw-r--r--test/test.cpp57
1 files changed, 56 insertions, 1 deletions
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;