Problem: When someone posts a comment and writes an url in the comment, the url is not automatically converted into a link.
Is there a plugin to do that? Any other solutions?
how to automatically convert URLs into Links
Re: how to automatically convert URLs into Links
... because HTML is not allowed in comments in Serendipity by default for some kind of security reason Garvin can explain way better than I canchessnut wrote:Problem: When someone posts a comment and writes an url in the comment, the url is not automatically converted into a link.
There's the event plugin "Transforms HTML for comments" (serendipity_event_unstrip_tags), which is available via http://spartacus.s9y.org.chessnut wrote:Is there a plugin to do that? Any other solutions?
YL
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: how to automatically convert URLs into Links
Hi!
The problem of automatic link conversion is still that the regexp to auto-convert a link is very hard and complicated, even though it sounds a very easy thing to do.
Every time when this issue comes up on the forums, I ask people if they have a code example or regexp that we could use...because I don't have a reliable one
Regards,
Garvin
The problem of automatic link conversion is still that the regexp to auto-convert a link is very hard and complicated, even though it sounds a very easy thing to do.
Every time when this issue comes up on the forums, I ask people if they have a code example or regexp that we could use...because I don't have a reliable one
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: how to automatically convert URLs into Links
Thanks for the suggestion! But I don't want to give the user full html-capabilities. Furthermore I think most of the users are too lazy to write html-code for links.yellowled wrote:There's the event plugin "Transforms HTML for comments" (serendipity_event_unstrip_tags), which is available via http://spartacus.s9y.org.
Well, but what does the "Make external links clickable?"-Option in Configuration do then? Because urls and links (with html-tags <a href>) are not made clickable in the comments... And I also don't see any plugin that overwrites this behaviour.
Does it really have to be a perfect solution? Why not making one, that fits for most of the common links?garvinhicking wrote: Every time when this issue comes up on the forums, I ask people if they have a code example or regexp that we could use...because I don't have a reliable one
One of these here should fit:
http://www.google.ch/search?q=regexp+url
(BTW: phpBB uses a regExp that seems to work quite good...)
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: how to automatically convert URLs into Links
Hi!
Regards,
Garvin
This only applies to links displayed in the Top Referrers and Top Exits sidebar plugins.Well, but what does the "Make external links clickable?"-Option in Configuration do then? Because urls and links (with html-tags <a href>) are not made clickable in the comments... And I also don't see any plugin that overwrites this behaviour.![]()
IMHO yes, a partially working or XSS-affectionate solution isn't acceptable.Does it really have to be a perfect solution?
It doesn't work with "!" inside the URL. Something, that s9y does not strip and which might often occur.(BTW: phpBB uses a regExp that seems to work quite good...)
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: how to automatically convert URLs into Links
How can automatic linking be XSS-affectionate?garvinhicking wrote:IMHO yes, a partially working or XSS-affectionate solution isn't acceptable.Does it really have to be a perfect solution?
Wikipedia-Regexp works with "!".garvinhicking wrote:It doesn't work with "!" inside the URL. Something, that s9y does not strip and which might often occur.(BTW: phpBB uses a regExp that seems to work quite good...)
My suggestion: It would be good to start with a regexp from phpBB or Wikipedia and develop it further as bugreports come in.
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: how to automatically convert URLs into Links
Hi!
http://www.google.de"><script>alert(document.cookie);</script><span class="
this could be autoconverted to:
<a href="http://www.google.de"><script>alert(document.cookie);</script><span class=""></a>
That wouldn't be good, and there's the XSS.
Regards,
Garvin
Imagine this link from a user:How can automatic linking be XSS-affectionate?
http://www.google.de"><script>alert(document.cookie);</script><span class="
this could be autoconverted to:
<a href="http://www.google.de"><script>alert(document.cookie);</script><span class=""></a>
That wouldn't be good, and there's the XSS.
The plugin serendipity_event_regexpmarkup already hs a rule "ClickableURL". Maybe that could be used as a starting point, maybe it already is sufficient for your cases?My suggestion: It would be good to start with a regexp from phpBB or Wikipedia and develop it further as bugreports come in.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: how to automatically convert URLs into Links
definitly!garvinhicking wrote: The plugin serendipity_event_regexpmarkup already hs a rule "ClickableURL". Maybe that could be used as a starting point,
I did some tests with it:
Is not a problem, because parentheses ("()") are not parsed.<a href="http://www.google.de"><script>alert(document.cookie);</script><span class=""></a>
But angle-brackets ("<>") are not really part of the url-specification, right? so they could be excluded from the regexp, so XSS could be prevented. Or are there any other characters, that are critical for XSS?
but exclamation marks ("!") are also not parsed, so they would have to be included.