Closed (cannot reproduce)
Project:
Webform PHP
Version:
6.x-3.x-dev
Component:
Webform PHP
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Jun 2010 at 04:16 UTC
Updated:
14 Sep 2010 at 11:32 UTC
Regular expressions often require escape characters. If the regular expression below is entered, the escape characters are removed. I tried double escaping (\\/\\.\\+\\(\\)), but each time you save the snippet you have to remember to double the escapes again.
if (!preg_match('/^[-0-9 \/\.\+\(\)]+$/', $phone)) {
form_set_error('submitted][phone', t('Phone number contains invalid characters.'));
}
Comments
Comment #1
quicksketchThis is a PHP coding question. I don't provide support on writing your own custom validation or submission handlers.
FYI: Escaping characters is not needed when inside square brackets (other than "-"). Check up on your RegEx syntax.
Comment #2
toomanypets commentedThanks for the fast response! I'm pretty sure this is not a coding question, and I am keenly aware that you have no interest in debugging others' code -- no problem.
But the issue is ...
If I include a backslash anywhere in the "Additional validation" or "Additional processing" fields, the backslash is removed.
Try this.
1. Type \\\\\ the press Save configuration. Three of the backslashes have been removed.
2. Press Save configuration again. Another backslash has been removed.
3. Press Save configuration again. There's nothing left :(
This example may be silly, but it illustrates the underlying problem quite well. A real world example (where we can both agree that the RegEx syntax is correct) where this causes problems is:
The backslash in front of the D is removed when you save the form, trashing the pattern.
Thank you very much for your help.
Comment #3
toomanypets commentedComment #4
toomanypets commentedSince my original report I have updated both Webform (now running 6.x-3.2) and Webform PHP (now running 6.x-3.x-dev 2010-Aug-19). I can no longer reproduce this issue, but based on release notes I have no reason to believe that any codes changes were made that would have addressed this. Strange -- solar flares maybe...
Closing issue.