diff options
author | Thomas Wolf | 2021-06-10 21:41:13 +0000 |
---|---|---|
committer | Mickael Istria | 2021-06-11 07:17:45 +0000 |
commit | 7b3b9511ddd44036234e6519e2105ecb77d9ee22 (patch) | |
tree | 94a62247ca87103db54c396c2db4f850003cb141 | |
parent | a399de39bf42ddb450ee76a2cc9e926dd8bcfbb7 (diff) | |
download | eclipse.platform.text-7b3b9511ddd44036234e6519e2105ecb77d9ee22.tar.gz eclipse.platform.text-7b3b9511ddd44036234e6519e2105ecb77d9ee22.tar.xz eclipse.platform.text-7b3b9511ddd44036234e6519e2105ecb77d9ee22.zip |
Bug 574139 - URLHyperlinkDetector: scheme:// is not a hyperlinkY20210611-0900I20210611-2000
Make the behavior more consistent between handling quoted and unquoted
URLs:
https://
would not give a hyperlink, but
"https://" or "https:// "
would.
Change the code to not produce hyperlinks for the latter two.
Change-Id: I17f6c16fd96ada810bfc4f635e9d03e8cf5f596b
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.text/+/181809
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Mickael Istria <mistria@redhat.com>
-rw-r--r-- | org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java | 3 | ||||
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/URLHyperlinkDetector.java | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java index 8e79f41bd99..9de19b43ad4 100644 --- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java +++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java @@ -418,6 +418,9 @@ public class TextViewerTest { checkHyperlink(textViewer, 3, "https:// ", "[]"); checkHyperlink(textViewer, 3, "https:// foo", "[]"); checkHyperlink(textViewer, 3, "https://foo bar", "[https://foo]"); + checkHyperlink(textViewer, 3, "\"https://\" foo bar", "[]"); + checkHyperlink(textViewer, 3, "\"https:// \" foo bar", "[]"); + checkHyperlink(textViewer, 3, "\"https:// foo\" bar", "[]"); checkHyperlink(textViewer, 15, "https:// foo https://bar bar", "[https://bar]"); checkHyperlink(textViewer, 24, "https:// foo https://bar bar", "[https://bar]"); checkHyperlink(textViewer, 15, "<a href=\"test:https://bugs.eclipse.org/bugs\"></a>", "[https://bugs.eclipse.org/bugs]"); diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/URLHyperlinkDetector.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/URLHyperlinkDetector.java index 2ad08986701..96bdefe2555 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/URLHyperlinkDetector.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/URLHyperlinkDetector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -146,6 +146,10 @@ public class URLHyperlinkDetector extends AbstractHyperlinkDetector { urlLength= endOffset - urlOffsetInLine; } + if (urlOffsetInLine + urlLength == urlSeparatorOffset + 3) { + return null; // Only "scheme://" + } + // Set and validate URL string try { urlString= line.substring(urlOffsetInLine, urlOffsetInLine + urlLength); |