| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent edf8c6d commit a53997e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1429,7 +1429,7 @@ void URL::Parse(const char* input, | |||
| 1429 | 1429 | const char ch = p < end ? p[0] : kEOL; | |
| 1430 | 1430 | bool special = (url->flags & URL_FLAGS_SPECIAL); | |
| 1431 | 1431 | bool cannot_be_base; | |
| 1432 | - const bool special_back_slash = (special && ch == '\\'); | ||
| 1432 | + bool special_back_slash = (special && ch == '\\'); | ||
| 1433 | 1433 | ||
| 1434 | 1434 | switch (state) { | |
| 1435 | 1435 | case kSchemeStart: | |
@@ -1477,6 +1477,7 @@ void URL::Parse(const char* input, | |||
| 1477 | 1477 | url->flags &= ~URL_FLAGS_SPECIAL; | |
| 1478 | 1478 | special = false; | |
| 1479 | 1479 | } | |
| 1480 | + special_back_slash = (special && ch == '\\'); | ||
| 1480 | 1481 | buffer.clear(); | |
| 1481 | 1482 | if (has_state_override) | |
| 1482 | 1483 | return; | |
@@ -1521,6 +1522,7 @@ void URL::Parse(const char* input, | |||
| 1521 | 1522 | url->flags &= ~URL_FLAGS_SPECIAL; | |
| 1522 | 1523 | special = false; | |
| 1523 | 1524 | } | |
| 1525 | + special_back_slash = (special && ch == '\\'); | ||
| 1524 | 1526 | if (base->flags & URL_FLAGS_HAS_PATH) { | |
| 1525 | 1527 | url->flags |= URL_FLAGS_HAS_PATH; | |
| 1526 | 1528 | url->path = base->path; | |
@@ -1544,6 +1546,7 @@ void URL::Parse(const char* input, | |||
| 1544 | 1546 | url->flags |= URL_FLAGS_SPECIAL; | |
| 1545 | 1547 | special = true; | |
| 1546 | 1548 | state = kFile; | |
| 1549 | + special_back_slash = (special && ch == '\\'); | ||
| 1547 | 1550 | continue; | |
| 1548 | 1551 | } | |
| 1549 | 1552 | break; | |
@@ -1573,6 +1576,7 @@ void URL::Parse(const char* input, | |||
| 1573 | 1576 | url->flags &= ~URL_FLAGS_SPECIAL; | |
| 1574 | 1577 | special = false; | |
| 1575 | 1578 | } | |
| 1579 | + special_back_slash = (special && ch == '\\'); | ||
| 1576 | 1580 | switch (ch) { | |
| 1577 | 1581 | case kEOL: | |
| 1578 | 1582 | if (base->flags & URL_FLAGS_HAS_USERNAME) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,6 +81,52 @@ TEST_F(URLTest, Base3) { | |||
| 81 | 81 | EXPECT_EQ(simple.path(), "/baz"); | |
| 82 | 82 | } | |
| 83 | 83 | ||
| 84 | + TEST_F(URLTest, Base4) { | ||
| 85 | + const char* input = "\\x"; | ||
| 86 | + const char* base = "http://example.org/foo/bar"; | ||
| 87 | + | ||
| 88 | + URL simple(input, strlen(input), base, strlen(base)); | ||
| 89 | + | ||
| 90 | + EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED); | ||
| 91 | + EXPECT_EQ(simple.protocol(), "http:"); | ||
| 92 | + EXPECT_EQ(simple.host(), "example.org"); | ||
| 93 | + EXPECT_EQ(simple.path(), "/x"); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + TEST_F(URLTest, Base5) { | ||
| 97 | + const char* input = "/x"; | ||
| 98 | + const char* base = "http://example.org/foo/bar"; | ||
| 99 | + | ||
| 100 | + URL simple(input, strlen(input), base, strlen(base)); | ||
| 101 | + | ||
| 102 | + EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED); | ||
| 103 | + EXPECT_EQ(simple.protocol(), "http:"); | ||
| 104 | + EXPECT_EQ(simple.host(), "example.org"); | ||
| 105 | + EXPECT_EQ(simple.path(), "/x"); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + TEST_F(URLTest, Base6) { | ||
| 109 | + const char* input = "\\\\x"; | ||
| 110 | + const char* base = "http://example.org/foo/bar"; | ||
| 111 | + | ||
| 112 | + URL simple(input, strlen(input), base, strlen(base)); | ||
| 113 | + | ||
| 114 | + EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED); | ||
| 115 | + EXPECT_EQ(simple.protocol(), "http:"); | ||
| 116 | + EXPECT_EQ(simple.host(), "x"); | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + TEST_F(URLTest, Base7) { | ||
| 120 | + const char* input = "//x"; | ||
| 121 | + const char* base = "http://example.org/foo/bar"; | ||
| 122 | + | ||
| 123 | + URL simple(input, strlen(input), base, strlen(base)); | ||
| 124 | + | ||
| 125 | + EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED); | ||
| 126 | + EXPECT_EQ(simple.protocol(), "http:"); | ||
| 127 | + EXPECT_EQ(simple.host(), "x"); | ||
| 128 | + } | ||
| 129 | + | ||
| 84 | 130 | TEST_F(URLTest, TruncatedAfterProtocol) { | |
| 85 | 131 | char input[2] = { 'q', ':' }; | |
| 86 | 132 | URL simple(input, sizeof(input)); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments