To participate you must create an account on apostrophenow.com. If you have already done so, click Login.

Ticket #347 (closed enhancement: fixed)

Opened 4 months ago

Last modified 3 days ago

aFeedSlot - URLS in Description become links automatically

Reported by: johnnyoffline Owned by: wjohnald
Priority: critical Milestone: 1.5
Component: apostrophePlugin Version: trunk
Keywords: Cc: jake, rickybanister, geoffd, johnnyoffline, boutell
Symfony version: 1.4

Description

Tom,

I am marking this critical only because it's related to a client project.

We need an anchor tag aware scrubber that looks through incoming RSS feed posts for URLS that are -not- links and transforms them INTO links.

Example below is a twitter feed. We get shortened URLS from a plethora of sites but they aren't clickable:


Attachments

rss-twitter-example-urls-without-links.png (36.2 kB) - added by anonymous 4 months ago.

Change History

Changed 4 months ago by anonymous

Changed 4 months ago by boutell

  • owner changed from tboutell to boutell
  • status changed from new to accepted

The weird part here is that RSS message bodies usually contain HTML, yet these are not already linkified in the HTML. Fixing that without breaking RSS message bodies that *do* contain HTML is the tricky thing, we can't just call aHtml::textToHtml().

Changed 3 months ago by boutell

  • milestone changed from 1.4 to 1.5

This can be done at the app level and we can migrate the benefits into 1.5 later

Changed 2 weeks ago by agilbert

  • owner changed from boutell to wjohnald
  • status changed from accepted to assigned

Changed 2 weeks ago by wjohnald

This appears to be a non-issue as Symfony's TextHelper?'s auto_link_text already creates links from urls while ignoring existing links. After performing some unit tests, I rearranged the aHtml::textToHtml() function from:

return auto_link_text(simple_format_text(htmlentities($text, ENT_COMPAT, 'UTF-8')));

to

   	return simple_format_text(htmlentities(auto_link_text($text), ENT_COMPAT, 'UTF-8'));

I believe the problem was related to htmlentities replacing the characters needed by Symfony's regular expression before it had the chance to create the links. This seems to work fine, and I will commit my unit tests tomorrow.

Changed 2 weeks ago by wjohnald

Even better:

return htmlentities(simple_format_text(auto_link_text($text), ENT_COMPAT, 'UTF-8'));

Changed 2 weeks ago by tboutell

Looks like good detective work. I am a little surprised because I could've sworn the feed slot expected the post body to be HTML already and therefore probably wouldn't be calling textToHtml() on it; the issue as I understood it was that Twitter wasn't bothering to put HTML in their feed...? Is this solution safe for content that is already HTML, as feed items often are in other RSS feeds?

Changed 2 weeks ago by wjohnald

My unit tests are now in my trunk of the repository.

I have run a test that uses a mixed string (an HTML link "<a href="*">*</a>" and just a regular old text URL.

If passed a block of html code, it will linkify plain urls and add some extra formatting elements "<p>"s and "<br/>"s.

If auto_link_text is called alone, it will only linkify plain urls.

Changed 3 days ago by wjohnald

  • status changed from assigned to closed
  • resolution set to fixed

Resolved in commit [2107]

Note: See TracTickets for help on using tickets.