No Textile links in comments?

Creating and modifying plugins.
Post Reply
Bman
Posts: 3
Joined: Tue May 15, 2007 6:32 am
Location: San Diego, CA
Contact:

No Textile links in comments?

Post by Bman »

Hi, I'm using the Textile plugin for posts and comments on my blog, and while I have no problems with posts, I don't ever get any Textile links in comments people post, as seen in some of the comments here.

I am certain Textile is being applied to the comments, since all the rest of the markup (bold, italic, etc) works fine. But not links for whatever reason.

I've made sure "Make external links clickable?" is set to yes, I've tried changing the order of the spam filter plugin and the textile plugin, gone through all the spam filter settings, and even just deactivated the spam filter plugin entirely to see if it was responsible, and still no luck.

Is there something else I need to do in order to get the links working? Did I miss something completely obvious?

I'd really appreciate any help you can provide.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: No Textile links in comments?

Post by garvinhicking »

Hi!

Phew. Sadly I have no experience with Textile as such. But if you enter the same markup for a link that you entered for a comment into an article, it gets properly formatted there?

Which other markup plugins are you using? Maybe another one interfers on comments with Textile...?

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/
Bman
Posts: 3
Joined: Tue May 15, 2007 6:32 am
Location: San Diego, CA
Contact:

Post by Bman »

Hi Garvin,

That's right, the format for links in textile is:

Code: Select all

"link text":http://www.link.com/
It gets converted to links as expected when I create blog posts, but not in comments. (You can see this happening on comment #5 in the link I posted.)

Textile is the only markup plugin I have installed. The other plugins installed are:

Event:
Spartacus
Spam Protector
Link List
Browser Compatibility

Just tried disabling all of those and it didn't make any difference.

Sidebar:
HTML nugget (x5)
Quicksearch
Link list
Remote RSS
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Ah, it MIGHT be because s9y uses htmlspecialchars() on a comment which translates " to the quot;-Entity. Mabe this disturbs things.

So the textile plugin would need to be patched to also use quot; as a delimiter. Does the textile plugin maybe also accept the single quote ' within texts? Then you could try if that works?

For security means, s9y always escapes all comment input to prevent any XSS abuse, so sadly we can't prevent the use of it.... :-/


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/
Bman
Posts: 3
Joined: Tue May 15, 2007 6:32 am
Location: San Diego, CA
Contact:

Post by Bman »

Ahh, I'll bet that's exactly what's going on. The textile plugin for s9y definitely doesn't accept single-quote for links, and it doesn't look like the "official" converter does either. Go to that link and try:

Code: Select all

'this is a link':http://www.link.com/
"this is a link":http://www.link.com/
And you'll see that only the second one gets converted to an HTML link. I'm guessing the fix would be to update the regex in the Textile plugin so that it'll recognize " in addition to ".

So this should fix it:

This is the original links handler, from textile.php:

Code: Select all

    function textile_links($text)
    {
        global $textile_c;
        return preg_replace_callback('/
            ([\s[{(]|[[:punct:]])?     # $pre
            "                          # start
            ('.$textile_c.')                   # $textile_atts
            ([^"]+)                  # $text
            \s?
            (?:\(([^)]+)\)(?="))?    # $title
            ":
            (\S+\b)                    # $url
            (\/)?                      # $textile_slash
            ([^\w\/;]*)                # $post
            (?=\s|$)
        /Ux',"textile_fLink",$text);
    }
It would need to be changed to:

Code: Select all

    function textile_links($text)
    {
        global $textile_c;
        return preg_replace_callback('/
            ([\s[{(]|[[:punct:]])?     # $pre
            (?:"|")                  # start  <<CHANGED
            ('.$textile_c.')                   # $textile_atts
            ([^"]+)                  # $text
            \s?
            (?:\(([^)]+)\)(?="))?    # $title
            (?:"|"):          <<CHANGED
            (\S+\b)                    # $url
            (\/)?                      # $textile_slash
            ([^\w\/;]*)                # $post
            (?=\s|$)
        /Ux',"textile_fLink",$text);
    }
That seems to have fixed it on my blog without causing anything to break. (You can see that comments now have the correct links in the thread I linked before.) I leave the determination of how you'd like to integrate the fix into s9y itself in your capable hands. :)

Thanks for the help!
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Hey, cool, seems I guessed the right way. :)

Your patch is exactly what I would have done as well. Sorry for not providing this earlier on, I was a bit in a hurry. I committed that patch for the serendipity 1.3 version tree. I didn't date to put it into the 1.2 RCs because of possible b0rkage (even though I expected none).

Many thanks,
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/
Bodehase
Regular
Posts: 36
Joined: Wed Aug 27, 2008 2:29 am
Contact:

Post by Bodehase »

Is this fixed in the textile-Plugin-Version 1.6?
It seems to me, that it is still not working...
Weblog: Bodehase
s9y-Plugin: ebayauctions 0.9.1 beta
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Yes, it's fixed in 1.6, which comes with the latest versions.

The textile formatting will not be replaced if it's in a <php>, <output>, or <name> block. It might not be replaced if the "unescape" option isn't true. And of course, only double-quotes are allowed.

Check your HTML and configuration to make sure the tag is eligible for replacement.
Judebert
---
Website | Wishlist | PayPal
Post Reply