-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NUTCH-3087 BasicURLNormalizer to keep userinfo for protocols which mi…
…ght require it - strip the userinfo from the authority only for HTTP and HTTPS
- Loading branch information
1 parent
86b893a
commit df115cb
Showing
2 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,6 +216,32 @@ public void testNormalizer() throws Exception { | |
normalizeTest("file:/var/www/html/////./bar/index.html", | ||
"file:/var/www/html/bar/index.html"); | ||
} | ||
|
||
@Test | ||
public void testNUTCH3087() throws Exception { | ||
// NUTCH-3087 userinfo to be kept in URLs with protocols usually requiring | ||
// authentication | ||
normalizeTest("ftp://[email protected]/path/file.txt", | ||
"ftp://[email protected]/path/file.txt"); | ||
normalizeTest("ftp://[email protected]/", | ||
"ftp://[email protected]/"); | ||
normalizeTest("ftp://user:[email protected]/path/file.txt", | ||
"ftp://user:[email protected]/path/file.txt"); | ||
// But for HTTP(S) the userinfo should be removed. | ||
// (example from https://en.wikipedia.org/wiki/Uniform_Resource_Identifier) | ||
normalizeTest( | ||
"https://[email protected]:1234/forum/questions/?tag=networking&order=newest#top", | ||
"https://www.example.com:1234/forum/questions/?tag=networking&order=newest"); | ||
// URLs with IPv6 address | ||
normalizeTest("ftp://user@[2600:1f18:200d:fb00:2b74:867c:ab0c:150a]/../path/file.txt", | ||
"ftp://user@[2600:1f18:200d:fb00:2b74:867c:ab0c:150a]/path/file.txt"); | ||
normalizeTest("https://user@[2600:1f18:200d:fb00:2b74:867c:ab0c:150a]/", | ||
"https://[2600:1f18:200d:fb00:2b74:867c:ab0c:150a]/"); | ||
normalizeTest("https://user@[2600:1f18:200d:fb00:2b74:867c:ab0c:150a]:443/", | ||
"https://[2600:1f18:200d:fb00:2b74:867c:ab0c:150a]/"); | ||
normalizeTest("https://user@[2600:1f18:200d:fb00:2b74:867c:ab0c:150a]/path/../to/index.html", | ||
"https://[2600:1f18:200d:fb00:2b74:867c:ab0c:150a]/to/index.html"); | ||
} | ||
|
||
@Test | ||
public void testCurlyBraces() throws Exception { | ||
|