Before rolling a patch for this, I figured I would gauge controversy. ;)

For the uninitiated, urlfilter module automatically translates the word "http://drupal.org" into a URL to http://drupal.org. I'm hard-pressed to find a plausible example of why one would not want this functionality by default (though of course switch-offable).

Let the flames begin. ;)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

beginner’s picture

+1.
Nobody is maintaining it, now:
http://drupal.org/node/65116 .

beginner’s picture

Well, I guess there is not much controversial about this idea...
As of today, nobody but core commiters can commit anything to it, anyway.
See again the issue I mentioned above.

Michelle’s picture

+1 from me. I'm on a photo site that doesn't have this functionality and it's one of the most complained about things. I wouldn't think of running a site that allows users to post without having this module. To expect users to know how to put in an a href is silly. :)

Michelle

webchick’s picture

Status: Active » Needs review
FileSize
6.86 KB

Finally got around to rolling a patch for this. Needs testing; I've never done stuff w/ filter module before.

webchick’s picture

FileSize
7.13 KB

Based on a review from Steven on IRC, I changed the following things:

1. The two helper functions I totally misunderstood. :P Renamed and re-PHPdoced to hopefully be more clear.
2. During the update, it now checks for the existence of urlfilter module, and if found will disable it.

Steven’s picture

I was thinking for the urlfilter update, inserting new filter entries into a site's formats is a bad idea. Plus, the current update only disables urlfilter.module, but leaves the old entries around. This is not a problem per-se, as function_exists is used to verify filters, but it's still messy. We should only convert existing urlfilter usage to the core one.

Other than this, thumbs up from me. Sure, it's the monster regexp from hell times 3, but it gets the job done better than all the other linkers I've seen. :P

Dries’s picture

+1 from me. It's critical functionality.

webchick’s picture

FileSize
6.45 KB

Ok cool, this patch removes the update path.

Testers, please. :)

webchick’s picture

Assigned: Unassigned » webchick
webchick’s picture

FileSize
7.24 KB

Steven found me on IRC and informed me that I totally misunderstood his last comment. ;) Don't get rid of the update hook; rather, convert any existing urlfilter entries to use the core version.

Attached patch does this (I hope :)).

robertDouglass’s picture

Ah, nice! I'll definitely be testing this so that we can hit the code freeze. Nice call, webchick, this is always one of the first modules I install.

Dries’s picture

First review:

  • +         return t('Automatically converts URLs such as http://www.example.com and ftp://www.example.com, and e-mail addresses such as example@example.com, into links.');
    

    Do we really need to show people what URLs and e-mail addresses look like? I mean ... :-)

  • Change URL Filter to URL filter.
  • Shouldn't we use truncate_utf8() instead of substr to safely truncate UTF-8 strings.
  • No messing around with globals please (hidden paramater passing makes for really ugly code):
    +  global $urlfilter_length;
    +  $urlfilter_length = variable_get('filter_url_length_'. $format, 72);
    
Dries’s picture

Status: Needs review » Needs work
introfini’s picture

It’s possible to add an option for the nofollow attribute?

Thanks,
introfini

Steven’s picture

I never added it because it's already in the HTML filter. But I guess with the default weights, the urlfilter is placed after the HTML filter. Options:
1) Place urlfilter before html filter (easy)
2) Split off nofollow filter and put it at the end (more work)

robertDouglass’s picture

It seems like on August 29th, two days before the code freeze, the appropriate thing is would be to get the URL filter in and open an issue to split off the nofollow functionality for the next iteration.

Anonymous’s picture

please add this to core.. +++++1

m3avrck’s picture

Wow, about darn tooting time!

return t('Web page addresses and e-mail addresses turn into links automatically.');
and

case 3:
          return t('Turns web and e-mail addresses into clickable links.');

More concise, "Turns URLs into links automatically"

Should URL fitler go last as spot 3? Wouldn't it make sense to parse the URLs first, *before* line breaks? Just thinking about URLs that wrap...

Steven’s picture

Status: Needs work » Fixed

Committed a tweaked patch to HEAD.

  • Found the middle road between m3avrick's and Dries' text. IMO the word 'URL' is too technical.
  • Shouldn't we use truncate_utf8() instead of substr to safely truncate UTF-8 strings.

    Nope, as the regular expression does not match non-ascii characters. In any case, it is preferred to use drupal_substr() rather than truncate_utf8(), as the former counts in characters rather than bytes (and thus more closely matches visual length).

  • No messing around with globals please (hidden paramater passing makes for really ugly code):

    Well, I changed it to a static var instead which is passed in first. It's a preg_replace_callback callback, so it can't take in extra arguments during the replacing.

  • The update was still rather bad as it inserted the URLfilter blindly into formats 1 and 3. This means that people who use e.g. bbcode or textile on their website will get an undesirable filter in. I removed this. When upgrading from 4.7, you only get the URLfilter enabled if you used urlfilter.module before. With a fresh install of HEAD, you will get URLfilter by default.
  • I moved the urlfilter before the HTML filter in the filter order, that way the rel="nofollow" works on autogenerated links too.
  • The length setting didn't work, as the form item name didn't match the variable name.
webchick’s picture

Hey, thanks a lot Steven. I really appreciate you picking up my slack.

Anonymous’s picture

Status: Fixed » Closed (fixed)