Closed hanneshal closed 2 years ago
If I type create note or write an answer and paste or type a valid link, I expect it to be valid after the submit.
If I paste a link, within a sentence like:
Hello please visit our website here: https://www.domain.com/foobar/blub.php.
And the user submits this the link is detected, incl. the "." at the end. Which results in an error.
The source of this problem is in https://github.com/znuny/Znuny/blob/rel-6_1-dev/Kernel/System/HTMLUtils.pm#L926 (and above).
A diff with a simple hotfix is attached:
diff --git a/Kernel/System/HTMLUtils.pm b/Kernel/System/HTMLUtils.pm index 1bdb932146..98b05d8739 100644 --- a/Kernel/System/HTMLUtils.pm +++ b/Kernel/System/HTMLUtils.pm @@ -923,6 +923,10 @@ sub LinkQuote { $DisplayLink .= $Link; $HrefLink .= $Link; } + + # remove trailing dots in href link + $HrefLink =~ s{\.+\z}{}; + $Start . "<a href=\"$HrefLink\"$Target title=\"$HrefLink\">$DisplayLink<\/a>" . $End; }egxism; diff --git a/scripts/test/HTMLUtils/LinkQuote.t b/scripts/test/HTMLUtils/LinkQuote.t index f0857f34a7..5236db48db 100644 --- a/scripts/test/HTMLUtils/LinkQuote.t +++ b/scripts/test/HTMLUtils/LinkQuote.t @@ -163,6 +163,13 @@ my @Tests = ( Name => 'LinkQuote with plain domains.', Target => '', }, + { + Input => '<html>www.heise.de.</html>', + Result => + '<html><a href="http://www.heise.de" title="http://www.heise.de">www.heise.de.</a></html>', + Name => 'LinkQuote with plain domains.', + Target => '', + }, { Input => '<html>xwww.heise.de</html>', Result => '<html>xwww.heise.de</html>', @@ -190,6 +197,13 @@ my @Tests = ( Name => 'LinkQuote with plain domains with a dash.', Target => '', }, + { + Input => '<html>www.heise-online.de/Suffix.</html>', + Result => + '<html><a href="http://www.heise-online.de/Suffix" title="http://www.heise-online.de/Suffix">www.heise-online.de/Suffix.</a></html>', + Name => 'LinkQuote with plain domains with a dash.', + Target => '', + }, { Input => '<html>ftp.heise.de/Suffix</html>', Result =>
I recommend to re evaluate the logic behind this and also check why the "autolink" of the CKEditor is not used in this case.
Steps to reproduce the behaviour:
Fixed with 64aa443dc5d4dfc14db58b632f6c9e299074ca70 (dev) and ea35a4bf78278ba6afee613da4e05bf1b7330514 (rel-6_0-dev)
Environment
Expected behaviour
If I type create note or write an answer and paste or type a valid link, I expect it to be valid after the submit.
Actual behaviour
If I paste a link, within a sentence like:
And the user submits this the link is detected, incl. the "." at the end. Which results in an error.
The source of this problem is in https://github.com/znuny/Znuny/blob/rel-6_1-dev/Kernel/System/HTMLUtils.pm#L926 (and above).
A diff with a simple hotfix is attached:
I recommend to re evaluate the logic behind this and also check why the "autolink" of the CKEditor is not used in this case.
How to reproduce
Steps to reproduce the behaviour:
Additional information
Screenshots