Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
AlexisWilke CreditAttribution: AlexisWilke commentedYou 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.
Comment #2
nikhiljain CreditAttribution: nikhiljain commentedThanks Alexis. I am using a WYSIWYG editor. Can you tell me how exactly I can integrate this with the URL Filter?
Comment #3
AlexisWilke CreditAttribution: AlexisWilke commentedPosted 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
Comment #4
nikhiljain CreditAttribution: nikhiljain commentedActually 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.
Comment #5
AlexisWilke CreditAttribution: AlexisWilke commentedSorry, I thought you said "custom" filter... my bad 8-)
Comment #6
apadernoI am closing this issue, since it's for a Drupal version no longer supported.