Skip to content
Snippets Groups Projects
Commit 91ea2d81 authored by Demian Katz's avatar Demian Katz
Browse files

Added trimming of slashes/whitespace to query builder.

parent abda73a4
No related merge requests found
......@@ -547,6 +547,10 @@ class QueryBuilder implements QueryBuilderInterface
$input = preg_replace($parenRegex, '', $input);
}
// Remove surrounding slashes and whitespace -- these serve no purpose
// and can cause problems.
$input = trim($input, '/ ');
return $input;
}
......
......@@ -136,7 +136,7 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase
array("()", "*:*"), // empty parens
array("((()))", "*:*"), // nested empty parens
array("((())", "*:*"), // mismatched parens
array("this that ()", "this that "), // text mixed w/ empty parens
array("this that ()", "this that"), // text mixed w/ empty parens
array('"()"', '"()"'), // empty parens in quotes
array('title - sub', 'title sub'), // freestanding hyphen
array('"title - sub"', '"title - sub"'),// freestanding hyphen in quotes
......@@ -154,6 +154,7 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase
array('^10', '10'), // invalid boosts
array('test^ test^6', 'test test6'), // invalid boosts
array('test^1 test^2', 'test^1 test^2'),// valid boosts
array('title /', 'title'), // trailing slash
);
// @codingStandardsIgnoreEnd
......
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