Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • james 37 posts 121 karma points c-trib
    Aug 01, 2013 @ 12:14
    james
    0

    Ampersands in regular expressions

    Hello,

    I have an email address on my form which is validated against the following regular expression:

    ^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$

    When the expression is output into the markup the ampersands are HTML encoded giving the following regex:

    ^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$

    Is there any way I can stop the ampersands from being HTML encoded?

  • Comment author was deleted

    Aug 01, 2013 @ 12:31

    Yeah update the views to use Html.Raw() will also fix this in the next maintenance release

    Details on customizing the views can be found here http://our.umbraco.org/projects/umbraco-pro/contour/documentation/Developer/Custom-Markup/

  • Comment author was deleted

    Aug 01, 2013 @ 12:32
  • james 37 posts 121 karma points c-trib
    Aug 01, 2013 @ 13:03
    james
    0

    Thanks Tim, your workaround works for me :)

  • Comment author was deleted

    Aug 01, 2013 @ 13:06

    Cool thanks for confirming :)

Please Sign in or register to post replies

Write your reply to:

Draft