Skip to content

Commit df25fda

Browse files
authored
Merge pull request #224 from phpcr/escape-single-quotes
escape single quotes in sql generator
2 parents 778bc5a + 7b1cbce commit df25fda

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ Changelog
44
2.x
55
---
66

7+
2.0.1
8+
-----
9+
10+
* The SQL generator now escapes single quotes `'`. This avoids SQL injection risks. If you escaped
11+
strings manually (by duplicating the `'`) you will need to stop doing that as otherwise the query
12+
will be run with duplicated single quotes.
13+
714
2.0.0
815
-----
916

src/PHPCR/Util/QOM/BaseSqlGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function evalLiteral(mixed $literal): string
214214
return $this->evalCastLiteral($string, 'DOUBLE');
215215
}
216216

217-
return "'$literal'";
217+
return sprintf("'%s'", str_replace("'", "''", $literal));
218218
}
219219

220220
/**

0 commit comments

Comments
 (0)