diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php index 8396c6b..d3f3ad4 100644 --- a/core/modules/views/src/Plugin/views/HandlerBase.php +++ b/core/modules/views/src/Plugin/views/HandlerBase.php @@ -707,12 +707,12 @@ public static function breakString($str, $force_int = FALSE) { // Determine if the string has 'or' operators (plus signs) or 'and' // operators (commas) and split the string accordingly. - if (preg_match('/^([\w0-9-_\.]+[+ ]+)+[\w0-9-_\.]+$/u', $str)) { + if (preg_match('/^([\w0-9-_\.\#\&\/]+[+ ]+)+[\w0-9-_\.\#\&\/]+$/u', $str)) { // The '+' character in a query string may be parsed as ' '. $operator = 'or'; $value = preg_split('/[+ ]/', $str); } - elseif (preg_match('/^([\w0-9-_\.]+[, ]+)*[\w0-9-_\.]+$/u', $str)) { + elseif (preg_match('/^([\w0-9-_\.\#\&\/]+[, ]+)*[\w0-9-_\.\#\&\/]+$/u', $str)) { $operator = 'and'; $value = explode(',', $str); } diff --git a/core/modules/views/src/Tests/Handler/HandlerTest.php b/core/modules/views/src/Tests/Handler/HandlerTest.php index e07beb3..263b802 100644 --- a/core/modules/views/src/Tests/Handler/HandlerTest.php +++ b/core/modules/views/src/Tests/Handler/HandlerTest.php @@ -103,6 +103,18 @@ public function testBreakString() { $handler = HandlerBase::breakString('wõrd1,wõrd2,wõrd'); $this->assertEqualValue(['wõrd1', 'wõrd2', 'wõrd'], $handler); $this->assertEqual('and', $handler->operator); + $handler = HandlerBase::breakString('Law & Order,word,word'); + $this->assertEqualValue(['Law & Order', 'word', 'word'], $handler); + $this->assertEqual('and', $handler->operator); + $handler = HandlerBase::breakString('word,Law & Order,word'); + $this->assertEqualValue(['word','Law & Order', 'word'], $handler); + $this->assertEqual('and', $handler->operator); + $handler = HandlerBase::breakString('word,#Law&Order,word'); + $this->assertEqualValue(['word','#Law&Order', 'word'], $handler); + $this->assertEqual('and', $handler->operator); + $handler = HandlerBase::breakString('word,word,Law/Order'); + $this->assertEqualValue(['word','word', 'Law/Order'], $handler); + $this->assertEqual('and', $handler->operator); // Test a single word $handler = HandlerBase::breakString('word');