Checkout manager regex problems

Hi, I’ve been trying to implement the custom field validation via regex expressions, but have so far failed to get it to work. I was not sure what the problem was until I double checked the regex expression and noticed it was changed upon saving:

Working regex expression entered in the ‘regex string’ field:

^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[13-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$

Actual contents of the field after saving changes:

^(?:(?:31(\\/|-|\\.)(?:0?[13578]|1[02]))\\1|(?:(?:29|30)(\\/|-|\\.)(?:0?[13-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(\\/|-|\\.)0?2\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\\d|2[0-8])(\\/|-|\\.)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$

As you can see, all backslash characters (\) are automatically being escaped into double back slashes (\\), rendering the expression useless and thus preventing valid input from being accepted.

Is there any way to prevent this from happening?

Thanks in advance for any help you can provide

As a quick followup, I just made several changes to other checkout fields and re-checked the regex expression out of curiosity. It’s worse. It appears backslashes keep getting escaped again every time options are saved.

Currently my regex expression looks like this:

^(?:(?:31(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/|-|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\.)(?:0?[13578]|1[02]))\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\1|(?:(?:29|30)(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/|-|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\.)(?:0?[13-9]|1[0-2])\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\2))(?:(?:1[6-9]|[2-9]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\d)?\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\d{2})$|^(?:29(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/|-|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\.)0?2\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\3(?:(?:(?:1[6-9]|[2-9]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\d|2[0-8])(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/|-|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\.)(?:(?:0?[1-9])|(?:1[0-2]))\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\4(?:(?:1[6-9]|[2-9]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\d)?\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\d{2})$

So, yes, this is definitely a problem with WordPress auto escaping backslashes on save but not re-interpreting them on retrieve.

This kinda turns the whole custom validation field useless. Hope there’s a fix for this soon.

Hello @KamikaZEN,

I suspect that this is a bug in the latest plugin release. We have alerted our developer on this and added this in our issue tracker for further investigation.

Please bear with us.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.