-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
While detecting Username and password in url we were not breaking the… (
#31) * While detecting Username and password in url we were not breaking the iteration if we find the : This meanst that if there was a long substring of : then we will iterate till the end of the : string and then restart the same iteration for the next :. This fix breaks the usename and password detection when it encounters the next : thus breaking the look early and backtracking less. * Adding a test case for a valid URL between colons
- Loading branch information
1 parent
37a1e0f
commit 173c6db
Showing
3 changed files
with
19 additions
and
2 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
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 |
---|---|---|
|
@@ -644,6 +644,23 @@ public void testIpv6ZoneIndicesWithUrlEncodedDots(String address, String zoneInd | |
runTest(validUrl, UrlDetectorOptions.Default, validUrl); | ||
} | ||
|
||
@Test | ||
public void testColonEmbededurl() { | ||
runTest("::::::::::::::::::::::http://username:[email protected]:::::::::::::::", | ||
UrlDetectorOptions.Default, "http://username:[email protected]"); | ||
} | ||
@Test | ||
public void testNegativeArraySizeException() { | ||
String rawtext = "How ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\\n\\nCome "; | ||
List<Url> urls = null; | ||
try { | ||
UrlDetector detector = new UrlDetector(rawtext, UrlDetectorOptions.Default); | ||
urls = detector.detect(); | ||
} catch (NegativeArraySizeException e ) { | ||
Assert.fail(e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void testBacktrackInvalidUsernamePassword() { | ||
runTest("http://hello:asdf.com", UrlDetectorOptions.Default, "asdf.com"); | ||
|
173c6db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a fork of this project at https://github.com/URL-Detector/URL-Detector which fixes several other issues as well, since the issues were lingering here without attention for several years. Is there any interest at LinkedIn in trying to unify these back into a single codebase?