mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 13:02:19 +00:00
[FIXED HUDSON-6252] fix bad index calculation in SubText.subText which
caused StringIndexOutOfBoundsException in UrlAnnotator. Added test. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@30102 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
be39749c1d
commit
c2fd840846
2 files changed
+16
-3
No files matched your search
@@ -28,8 +28,6 @@ import hudson.MarkupText.SubText;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.net.URL;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
@@ -101,5 +99,20 @@ public class MarkupTextTest extends TestCase {
|
||||
assertEquals("Line<hr/>\n2 & 3\n<End>\n", text.toString(true));
|
||||
}
|
||||
|
||||
/* @Bug(6252) */
|
||||
public void testSubTextSubText() {
|
||||
MarkupText text = new MarkupText("abcdefgh");
|
||||
SubText sub = text.subText(2, 7);
|
||||
assertEquals("cdefg", sub.getText());
|
||||
sub = sub.subText(1, 4);
|
||||
assertEquals("def", sub.getText());
|
||||
|
||||
// test negative end
|
||||
sub = text.subText(2, -3);
|
||||
assertEquals("cdef", sub.getText());
|
||||
sub = sub.subText(1, -2);
|
||||
assertEquals("de", sub.getText());
|
||||
}
|
||||
|
||||
private static final Pattern pattern = Pattern.compile("issue #([0-9]+)");
|
||||
}
|
||||
Reference in new issue
Block a user