Fix tests revealed to be failing

* UriUtils.java
    isLikelyFalsePositive() - do not flag urls starting with ../ as likely false positives
* UriUtilsTest.java
    remove test url that is now rejected
This commit is contained in:
Noah Levitt
2012-06-06 09:00:13 -07:00
parent 342ea33be5
commit 99acaa9bfa
2 changed files with 2 additions and 9 deletions
@@ -273,8 +273,7 @@ public class UriUtils {
}
return true;
}
if (TextUtils.matches("^\\.\\.?[^/].*", candidate)) {
if (candidate.charAt(0) == '.' && !TextUtils.matches("^\\.{1,2}/.*", candidate)) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("rejected: starts with '.' (but not './' or '../'): " + candidate);
}
@@ -110,7 +110,6 @@ public class UriUtilsTest extends TestCase {
"cssp!gelui-1/overlay",
"/wiki/%E0%B4%B8%E0%B4%B9%E0%B4%BE%E0%B4%AF%E0%B4%82:To_Read_in_Malayalam",
"/wiki/Wikiversity:Why_create_an_account%3F",
";s.channel=d.channel?d.channel:"
};
public void testRelatives() {
tryAll(urisRelative, true);
@@ -237,12 +236,7 @@ public class UriUtilsTest extends TestCase {
*/
protected void tryAll(String[] candidates, boolean expected) {
for (String candidate : candidates) {
assertEquals("new: " + candidate,
expected,
UriUtils.isLikelyUri(candidate));
assertEquals("html context: " + candidate,
expected,
UriUtils.isLikelyUri(candidate));
assertEquals(candidate, expected, UriUtils.isLikelyUri(candidate));
}
}
}