Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-08-15 14:33:04 -0400
committerspingel2008-08-15 14:33:04 -0400
commitf7a0decd17827c154cfddf9936bd863f681dffbc (patch)
treec0cd86e94baee4e7c5a1b6a700cf1a0453928721
parent89a18d824839eafdee65fdd0cf77132196126b36 (diff)
downloadorg.eclipse.mylyn.tasks-f7a0decd17827c154cfddf9936bd863f681dffbc.tar.gz
org.eclipse.mylyn.tasks-f7a0decd17827c154cfddf9936bd863f681dffbc.tar.xz
org.eclipse.mylyn.tasks-f7a0decd17827c154cfddf9936bd863f681dffbc.zip
NEW - bug 244017: Hyperlinking support for Trac should handle disabled (escaped) links.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=244017 NEW - bug 244017: Hyperlinking support for Trac should handle disabled (escaped) links. https://bugs.eclipse.org/bugs/show_bug.cgi?id=244017
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracHyperlinkUtilTest.java28
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtil.java21
2 files changed, 39 insertions, 10 deletions
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracHyperlinkUtilTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracHyperlinkUtilTest.java
index c1a69fdf3..d123cd145 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracHyperlinkUtilTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracHyperlinkUtilTest.java
@@ -17,6 +17,11 @@ import org.eclipse.mylyn.internal.trac.ui.WebHyperlink;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TaskHyperlink;
+/**
+ * @author Steffen Pingel
+ * @author David Green
+ * @see http://trac.edgewall.org/wiki/TracLinks
+ */
public class TracHyperlinkUtilTest extends TestCase {
private TaskRepository repository;
@@ -78,6 +83,12 @@ public class TracHyperlinkUtilTest extends TestCase {
assertEquals(new Region(0, 5), links[0].getHyperlinkRegion());
assertEquals("http://localhost/changeset/123", ((WebHyperlink) links[0]).getURLString());
+ links = TracHyperlinkUtil.findTracHyperlinks(repository, "![123]", 0, 0);
+ assertNull(links);
+
+ links = TracHyperlinkUtil.findTracHyperlinks(repository, "![123]", 1, 0);
+ assertNull(links);
+
links = TracHyperlinkUtil.findTracHyperlinks(repository, "changeset:123", 0, 0);
assertEquals(1, links.length);
assertEquals(new Region(0, 13), links[0].getHyperlinkRegion());
@@ -153,6 +164,9 @@ public class TracHyperlinkUtilTest extends TestCase {
links = TracHyperlinkUtil.findTracHyperlinks(repository, "Page", 0, 0);
assertNull(links);
+ links = TracHyperlinkUtil.findTracHyperlinks(repository, "!Page", 0, 0);
+ assertNull(links);
+
links = TracHyperlinkUtil.findTracHyperlinks(repository, "ab Page dc", 0, 0);
assertNull(links);
@@ -165,6 +179,20 @@ public class TracHyperlinkUtilTest extends TestCase {
assertEquals("http://localhost/wiki/WikiPage", ((WebHyperlink) links[0]).getURLString());
assertEquals(new Region(0, 8), links[0].getHyperlinkRegion());
+ links = TracHyperlinkUtil.findTracHyperlinks(repository, "!WikiPage", 0, 0);
+ assertNull(links);
+
+ links = TracHyperlinkUtil.findTracHyperlinks(repository, "!WikiPage", 1, 0);
+ assertNull(links);
+
+ links = TracHyperlinkUtil.findTracHyperlinks(repository, "a WikiPage is here", 4, 0);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals("http://localhost/wiki/WikiPage", ((WebHyperlink) links[0]).getURLString());
+ assertEquals(new Region(2, 8), links[0].getHyperlinkRegion());
+
+ links = TracHyperlinkUtil.findTracHyperlinks(repository, "a !WikiPage is here", 4, 0);
+ assertNull(links);
}
public void testFindHyperlinksMilestone() {
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtil.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtil.java
index cea57af85..629a85011 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtil.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtil.java
@@ -28,6 +28,7 @@ import org.eclipse.mylyn.tasks.ui.TaskHyperlink;
* Utility class for detecting Trac hyperlinks.
*
* @author Steffen Pingel
+ * @author David Green fix for bug 244017
*/
public class TracHyperlinkUtil {
@@ -41,7 +42,7 @@ public class TracHyperlinkUtil {
static Pattern changesetPattern1 = Pattern.compile("(r|changeset:)(\\d+)(/\\w+)?");
- static Pattern changesetPattern2 = Pattern.compile("\\[(\\d+)(/\\w+)?\\]");
+ static Pattern changesetPattern2 = Pattern.compile("(?<![!])\\[(\\d+)(/\\w+)?\\]");
static Pattern revisionLogPattern1 = Pattern.compile("r(\\d+):(\\d+)");
@@ -55,7 +56,7 @@ public class TracHyperlinkUtil {
static Pattern wikiPattern1 = Pattern.compile("wiki:(\\w+)");
- static Pattern wikiPattern2 = Pattern.compile("[A-Z][a-z0-9]+[A-Z]\\w*");
+ static Pattern wikiPattern2 = Pattern.compile("(?<![!])[A-Z][a-z0-9]+[A-Z]\\w*");
static Pattern milestonePattern = Pattern.compile("milestone:([\\w\\.]+)");
@@ -146,8 +147,8 @@ public class TracHyperlinkUtil {
if (isInRegion(lineOffset, m)) {
String rev = m.group(1);
String stopRev = m.group(2);
- String url = repository.getRepositoryUrl() + ITracClient.REVISION_LOG_URL + "?rev=" + rev + "&stop_rev="
- + stopRev;
+ String url = repository.getRepositoryUrl() + ITracClient.REVISION_LOG_URL + "?rev=" + rev
+ + "&stop_rev=" + stopRev;
links.add(new WebHyperlink(determineRegion(regionOffset, m), url));
}
}
@@ -157,8 +158,8 @@ public class TracHyperlinkUtil {
if (isInRegion(lineOffset, m)) {
String rev = m.group(1);
String stopRev = m.group(2);
- String url = repository.getRepositoryUrl() + ITracClient.REVISION_LOG_URL + "?rev=" + rev + "&stop_rev="
- + stopRev;
+ String url = repository.getRepositoryUrl() + ITracClient.REVISION_LOG_URL + "?rev=" + rev
+ + "&stop_rev=" + stopRev;
links.add(new WebHyperlink(determineRegion(regionOffset, m), url));
}
}
@@ -244,8 +245,8 @@ public class TracHyperlinkUtil {
while (m.find()) {
if (isInRegion(lineOffset, m)) {
String page = m.group(1);
- links.add(new WebHyperlink(determineRegion(regionOffset, m), repository.getRepositoryUrl() + ITracClient.WIKI_URL
- + page));
+ links.add(new WebHyperlink(determineRegion(regionOffset, m), repository.getRepositoryUrl()
+ + ITracClient.WIKI_URL + page));
}
}
@@ -253,8 +254,8 @@ public class TracHyperlinkUtil {
while (m.find()) {
if (isInRegion(lineOffset, m)) {
String page = m.group(0);
- links.add(new WebHyperlink(determineRegion(regionOffset, m), repository.getRepositoryUrl() + ITracClient.WIKI_URL
- + page));
+ links.add(new WebHyperlink(determineRegion(regionOffset, m), repository.getRepositoryUrl()
+ + ITracClient.WIKI_URL + page));
}
}

Back to the top