Commit f6c0c692 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(attributes) Improve use of pattern attribute

issue #5910
Showing with 5 additions and 3 deletions
+5 -3
......@@ -56,8 +56,10 @@ class StringAttribute extends Attribute
function setPattern ($pattern)
{
$this->pattern = $pattern;
if (preg_match('/^(.)(.*)\1$/', $pattern, $m)) {
// First and last characters are the same means no modifiers are in use
if (preg_match('/^(.)\^(.*)\$\1$/', $pattern, $m)) {
/* Only convert anchored patterns
* First and last characters are the same means no modifiers are in use
*/
$this->html5pattern = $m[2];
} else {
$this->html5pattern = NULL;
......@@ -78,7 +80,7 @@ class StringAttribute extends Attribute
$attributes['autocomplete'] = ($this->autocomplete ? 'on' : 'off' );
}
if ($this->html5pattern !== NULL) {
$attributes['pattern'] = htmlentities($this->html5pattern, ENT_COMPAT, 'UTF-8');
$attributes['pattern'] = '{literal}'.htmlentities($this->html5pattern, ENT_COMPAT, 'UTF-8').'{/literal}';
}
if ($this->isRequired()) {
$attributes['required'] = 'required';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment