bug66141.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. --TEST--
  2. Bug #66141 (mysqlnd quote function is wrong with NO_BACKSLASH_ESCAPES after failed query)
  3. --SKIPIF--
  4. <?php
  5. require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
  6. require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
  7. MySQLPDOTest::skip();
  8. ?>
  9. --FILE--
  10. <?php
  11. include __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
  12. $db = MySQLPDOTest::factory();
  13. $input = 'Something\', 1 as one, 2 as two FROM dual; -- f';
  14. $quotedInput0 = $db->quote($input);
  15. $db->query('set session sql_mode="NO_BACKSLASH_ESCAPES"');
  16. // injection text from some user input
  17. $quotedInput1 = $db->quote($input);
  18. $db->query('something that throws an exception');
  19. $quotedInput2 = $db->quote($input);
  20. var_dump($quotedInput0);
  21. var_dump($quotedInput1);
  22. var_dump($quotedInput2);
  23. ?>
  24. done
  25. --EXPECTF--
  26. Warning: 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
  27. string(50) "'Something\', 1 as one, 2 as two FROM dual; -- f'"
  28. string(50) "'Something'', 1 as one, 2 as two FROM dual; -- f'"
  29. string(50) "'Something'', 1 as one, 2 as two FROM dual; -- f'"
  30. done