URLs can be easily filtered by this filter but I want to filter the content with anchor tags in comment.
Can "preg_match_all" be included for Anchor Tags with 'href'.

Comments

AlexisWilke’s picture

You have to come up with a regular expression that can catch those.

Assuming that the users cannot directly edit the HTML code, that's relatively easy:

<a[^>]+href=[^>]+>

This will detect an anchor with an href. However, browsers will generally accept a > inside an attribute written with quotes. Yet, if you use a WYSIWYG editor, I believe it will be difficult for a spammer to introduce such in the HTML code.

Edit: made the < and > show up as expected inside the code block.

nikhiljain’s picture

Thanks Alexis. I am using a WYSIWYG editor. Can you tell me how exactly I can integrate this with the URL Filter?

AlexisWilke’s picture

Posted by Jeremy on April 18, 2012 at 1:31pm

There are many regexp formulas available online that can help you write your custom filters:

For example:
http://blog.stevenlevithan.com/archives/validate-phone-number

(It's not clear to me if your issue is the writing of valid regular expressions, or something else.)

From #1537114: Cannot block phone numbers

nikhiljain’s picture

Actually it's a feature request. I wanted this functionality to be added in the current URL-Filter only as it is Anchor URL we are talking about.

AlexisWilke’s picture

Sorry, I thought you said "custom" filter... my bad 8-)

apaderno’s picture

Version: 6.x-1.4 » 6.x-1.x-dev
Issue summary: View changes
Status: Active » Closed (outdated)

I am closing this issue, since it's for a Drupal version no longer supported.