Skip to content

Commit eb4265e

Browse files
committed
Fixed SQL injection.
1 parent e64f855 commit eb4265e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/SQL/Compiler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function compileFunctionOpts($args){
8484
} else if ( $func_arg['type'] == 'function'){
8585
$out .= $this->compileFunction($func_arg['value'], false).', ';
8686
} else if ( $func_arg['type'] == 'text_val' ){
87-
$out .= "'".$func_arg['value']."', ";
87+
$out .= "'".addslashes($func_arg['value'])."', ";
8888
} else if ( $func_arg['type'] == 'expression' ){
8989

9090
$out .= $this->compileExpression($func_arg['type'], $func_arg['value']).", ";
@@ -138,7 +138,7 @@ function getWhereValue ($arg)
138138
$value = $arg['value'];
139139
break;
140140
case 'text_val':
141-
$value = '\''.$arg['value'].'\'';
141+
$value = '\''.addslashes($arg['value']).'\'';
142142
break;
143143
case 'subclause':
144144
$value = '('.$this->compileSearchClause($arg['value']).')';
@@ -209,7 +209,7 @@ function getParams($arg)
209209
$value[] = $arg['value'][$i];
210210
break;
211211
case 'text_val':
212-
$value[] = '\''.$arg['value'][$i].'\'';
212+
$value[] = '\''.addslashes($arg['value'][$i]).'\'';
213213
break;
214214
case 'function':
215215
$val = $this->compileFunction($arg['value'][$i]);
@@ -415,7 +415,7 @@ function compileSelect()
415415
break;
416416

417417
case 'text_val':
418-
$column = '\''.$this->tree['columns'][$i]['value'].'\'';
418+
$column = '\''.addslashes($this->tree['columns'][$i]['value']).'\'';
419419

420420

421421
if ( $this->tree['columns'][$i]['alias'] ){
@@ -638,7 +638,7 @@ function compileExpression($type, $val){
638638
case 'null':
639639
return $val;
640640
case 'text_val';
641-
return "'".$val."'";
641+
return "'".addslashes($val)."'";
642642
case 'ident':
643643
return $this->compileIdent($val);
644644
case 'function':
@@ -673,7 +673,7 @@ function compileInterval($val){
673673
$out .= $val;
674674
break;
675675
case 'text_val':
676-
$out .= "'".$val."'";
676+
$out .= "'".addslashes($val)."'";
677677
break;
678678
default:
679679
throw new Exception("Failed to compile interval. Wrong expression type ".$val['expression_type']);

0 commit comments

Comments
 (0)