Project

General

Profile

Actions

Bug #23557

closed

quoteStrForLike does not properly escape strings in sql_mode NO_BACKSLASH_ESCAPES

Added by Helmut Hummel over 13 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
-
Target version:
-
Start date:
2010-09-17
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.5
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

In this mode MySQL expects the quoting character to be explicitly set:

e.g.
SELECT 'David_' LIKE 'David\_' ESCAPE '\';

Solution:
set sql_mode='' during DBinit

Note:
It has to be checked if this is a proper solution and if this needs a bulletin.

SET sql_mode='NO_BACKSLASH_ESCAPES';
(issue imported from #M15737)


Files

15737_42.patch (1.26 KB) 15737_42.patch Administrator Admin, 2010-12-09 20:19
15737_43.patch (1.16 KB) 15737_43.patch Administrator Admin, 2010-12-09 20:19
15737_44.patch (1.16 KB) 15737_44.patch Administrator Admin, 2010-12-09 20:20
15737_45.patch (1.16 KB) 15737_45.patch Administrator Admin, 2010-12-09 20:20
Actions #1

Updated by Oliver Hader over 13 years ago

PoC:

$variable = "INJECT' UNION SELECT username,password FROM be_users; #";
$query = 'SELECT uid,pid FROM tt_content WHERE header LIKE ' . fullQuoteString($variable);

results in

SET sql_mode='NO_BACKSLASH_ESCAPES';
SELECT uid,pid FROM tt_content WHERE header LIKE 'INJECT\' UNION SELECT username,password FROM be_users; #';

Actions #2

Updated by Oliver Hader over 13 years ago

Setting the ESCAPE statement at the end of the query does not help since in the PoC given it's not evaluated since a comment started already:

SELECT uid,pid FROM tt_content WHERE header LIKE 'INJECT\' UNION SELECT username,password FROM be_users; #' ESCAPE '\';

Actions #3

Updated by Oliver Hader over 13 years ago

Since the SQL mode can contain other settings that are separated by comma, just unsetting the variable with "SET sql-mode='';" might introduce misbehaviours.

Thus, the NO_BACKSLASH_ESCAPES option shall be removed from the current session settings delivered by "SELECT @@SESSION.sql_mode;"

Actions #4

Updated by Xavier Perseguers over 13 years ago

You may use the setDBInit field in localconf.php for whatever you want with MySQL. This is not processed by DBAL for other DBMS.

Actions #5

Updated by Oliver Hader over 13 years ago

I attached patches that add a new methode setSqlMode() to t3lib_db which will be called after the setDBInit execution and will fix the NO_BACKSLASH_ESCAPES mode...

Actions #6

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF