xref: /PHP-8.2/ext/pdo_mysql/tests/bug66141.phpt (revision b5a14e6c)
1--TEST--
2Bug #66141 (mysqlnd quote function is wrong with NO_BACKSLASH_ESCAPES after failed query)
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
8MySQLPDOTest::skip();
9?>
10--FILE--
11<?php
12include __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
13$db = MySQLPDOTest::factory();
14
15$input = 'Something\', 1 as one, 2 as two  FROM dual; -- f';
16
17$quotedInput0 = $db->quote($input);
18
19$db->query('set session sql_mode="NO_BACKSLASH_ESCAPES"');
20
21// injection text from some user input
22
23$quotedInput1 = $db->quote($input);
24
25$db->query('something that throws an exception');
26
27$quotedInput2 = $db->quote($input);
28
29var_dump($quotedInput0);
30var_dump($quotedInput1);
31var_dump($quotedInput2);
32?>
33done
34--EXPECTF--
35Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'something that throws an exception' at line %d in %s on line %d
36string(50) "'Something\', 1 as one, 2 as two  FROM dual; -- f'"
37string(50) "'Something'', 1 as one, 2 as two  FROM dual; -- f'"
38string(50) "'Something'', 1 as one, 2 as two  FROM dual; -- f'"
39done
40