Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
804aded5
Commit
804aded5
authored
Jun 04, 2014
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`yii\sphinx\Connection::escapeMatchValue()` fixed
parent
62fdaeec
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
7 deletions
+29
-7
Connection.php
extensions/sphinx/Connection.php
+3
-4
QueryTest.php
tests/unit/extensions/sphinx/QueryTest.php
+26
-3
No files found.
extensions/sphinx/Connection.php
View file @
804aded5
...
@@ -138,11 +138,10 @@ class Connection extends \yii\db\Connection
...
@@ -138,11 +138,10 @@ class Connection extends \yii\db\Connection
*/
*/
public
function
escapeMatchValue
(
$str
)
public
function
escapeMatchValue
(
$str
)
{
{
$str
=
str_replace
(
return
str_replace
(
[
'\\'
,
'/'
,
'"'
,
"'"
,
'('
,
')'
,
'|'
,
'-'
,
'!'
,
'@'
,
'~'
,
'&'
,
'^'
,
'$'
,
'='
,
"
\x00
"
,
"
\n
"
,
"
\r
"
,
"
\x1a
"
],
[
'\\'
,
"'"
,
'/'
,
'"'
,
'('
,
')'
,
'|'
,
'-'
,
'!'
,
'@'
,
'~'
,
'&'
,
'^'
,
'$'
,
'='
,
"
\x00
"
,
"
\n
"
,
"
\r
"
,
"
\x1a
"
],
[
'\\\\'
,
'\\/'
,
'\\"'
,
"
\\
'"
,
'\\('
,
'\\)'
,
'\\|'
,
'\\-'
,
'\\!'
,
'\\@'
,
'\\~'
,
'\\&'
,
'\\^'
,
'\\$'
,
'
\\='
,
"
\\
x00"
,
"
\\
n"
,
"
\\
r"
,
"
\\
x1a"
],
[
'\\\\'
,
"
\\
'"
,
'\\\\/'
,
'\\\\"'
,
'\\\\('
,
'\\\\)'
,
'\\\\|'
,
'\\\\-'
,
'\\\\!'
,
'\\\\@'
,
'\\\\~'
,
'\\\\&'
,
'\\\\^'
,
'\\\\$'
,
'\\
\\='
,
"
\\
x00"
,
"
\\
n"
,
"
\\
r"
,
"
\\
x1a"
],
$str
$str
);
);
return
str_replace
(
'\\'
,
'\\\\'
,
$str
);
}
}
}
}
tests/unit/extensions/sphinx/QueryTest.php
View file @
804aded5
...
@@ -271,19 +271,42 @@ class QueryTest extends SphinxTestCase
...
@@ -271,19 +271,42 @@ class QueryTest extends SphinxTestCase
}
}
/**
/**
* Data provider for [[testMatchSpecialCharValue()]]
* @return array test data
*/
public
function
dataProviderMatchSpecialCharValue
()
{
return
[
[
"'"
],
[
'"'
],
[
'@'
],
[
'\\'
],
[
'()'
],
[
'\\'
.
"'"
],
[
"
\x00
"
],
[
"
\n
"
],
[
"
\r
"
],
[
"
\x1a
"
]
];
}
/**
* @dataProvider dataProviderMatchSpecialCharValue
* @depends testRun
* @depends testRun
*
*
* @param string $char char to be tested
*
* @see https://github.com/yiisoft/yii2/issues/3668
* @see https://github.com/yiisoft/yii2/issues/3668
*/
*/
public
function
testMatchSpecialCharValue
()
public
function
testMatchSpecialCharValue
(
$char
)
{
{
$connection
=
$this
->
getConnection
();
$connection
=
$this
->
getConnection
();
$query
=
new
Query
;
$query
=
new
Query
;
$rows
=
$query
->
from
(
'yii2_test_article_index'
)
$rows
=
$query
->
from
(
'yii2_test_article_index'
)
->
match
(
'about
\"'
)
->
match
(
'about
'
.
$char
)
->
all
(
$connection
);
->
all
(
$connection
);
$this
->
assert
NotEmpty
(
$rows
);
$this
->
assert
True
(
is_array
(
$rows
));
// no query error
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment