ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Ampersands not encoded in URLs?

August 08, 2008 11:27am

Subscribe [4]
  • #16 / Aug 13, 2008 9:00pm

    Mark Bowen

    12637 posts

    Okay now I really need to get some sleep. Just noticed in the Find and Replace plugin that it allows for regex.

    A very quick test and I came up with this :

    {exp:replace find="&(?!lt;|rt;|amp;)" replace="&" regex="yes"}
    <a href="http://www.example.com?test=one&two=two&ampthree=three">http://www.example.com?test=one&two=two&three=three</a>
    {/exp:replace}
    
    {exp:replace find="&(?!lt;|rt;|amp;)" replace="&" regex="yes"}
    {event_map_url}
    {/exp:replace}

    Seems to do the trick I think. I’m off to bed now. hope it helps.

    Best wishes,

    Mark

  • #17 / Aug 14, 2008 6:54am

    Low

    407 posts

    Actually, you could further specify the regex pattern to ignore all entities and only replace rogue ampersands (untested, but I think it’ll work):

    {exp:replace find="&(?!#?[a-zA-Z0-9]{2,6};)" replace="&" regex="yes"}
    ...
    {/exp:replace}
  • #18 / Aug 14, 2008 7:21am

    Mark Bowen

    12637 posts

    Actually, you could further specify the regex pattern to ignore all entities and only replace rogue ampersands (untested, but I think it’ll work):

    {exp:replace find="&(?!#?[a-zA-Z0-9]{2,6};)" replace="&" regex="yes"}
    ...
    {/exp:replace}

    Yep that as well 😉

    Was late last night so I was being quick (maybe that translates to lazy though 😉 )

    Thanks for such a great plugin by the way!! 😊

    Best wishes,

    Mark

  • #19 / Aug 14, 2008 8:59am

    44sunsets

    42 posts

    Wow that’s brilliant, thanks Mark and Low 😊

  • #20 / Aug 14, 2008 9:05am

    Mark Bowen

    12637 posts

    No problem at all. Thanks to Lowe for making the plugin in the first place though 😊

    Hopefully Justin won’t have started anything on this one yet Derek?

    Best wishes,

    Mark

  • #21 / Aug 14, 2008 11:39am

    Derek Jones

    7561 posts

    Justin’s plugin will do a bit more, making sure that supplied URLs are valid in other ways as well.  Thanks for stepping in with that, Low!

  • #22 / Aug 14, 2008 11:43am

    Low

    407 posts

    No problem, glad I could help.

  • #23 / Aug 14, 2008 11:47am

    Robin Sowell

    13255 posts

    I am jealous of the regex skills around here!  Glad all is very nicely squared away.  We good to close this one out?

  • #24 / Aug 14, 2008 12:23pm

    Mark Bowen

    12637 posts

    I am jealous of the regex skills around here!  Glad all is very nicely squared away.  We good to close this one out?

    Well actually I found it on the net that one but I have been trying to brush up on it all a little bit. Glad that it helped out though.

    Best wishes,

    Mark

  • #25 / Aug 14, 2008 2:21pm

    Mark Bowen

    12637 posts

    Justin’s plugin will do a bit more, making sure that supplied URLs are valid in other ways as well.  Thanks for stepping in with that, Low!

    Derek was just wondering what else will be done with Justin’s plugin? You mentioned making sure they are valid in other ways. Just wondering what you meant if you don’t mind.

    Best wishes,

    Mark

  • #26 / Aug 14, 2008 2:26pm

    Derek Jones

    7561 posts

    You’ll just need to wait on Justin, Mark. 😉

  • #27 / Aug 14, 2008 2:30pm

    Mark Bowen

    12637 posts

    You’ll just need to wait on Justin, Mark. 😉

    Okay, ‘nuff said 😊

  • #28 / Aug 17, 2008 1:28am

    44sunsets

    42 posts

    We good to close this one out?

    Fine by me 😊

  • #29 / Aug 17, 2008 11:10am

    Robin Sowell

    13255 posts

    😉  Closing this one out.  And looking forward to the plugin!

  • #30 / Aug 21, 2008 4:20pm

    Derek Jones

    7561 posts

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases