Skip to content

Commit

Permalink
MDL-29033 add tests for the sql injection hack
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Sep 9, 2011
1 parent bf0ddcb commit 040bd93
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/simpletest/testdmllib.php
Expand Up @@ -356,6 +356,23 @@ function test_backslashes_and_quotes() {




} }

function test_magic_hack() {
// test hacky sql injection protection - the resulting DB data is not really important,
// we only want to prevent SQL injections/DB errors

$obj = new stdClass();
$obj->textfield = 'lala\'';
$obj->id = insert_record($this->table, $obj);
$this->assertFalse(empty($obj->id));

$obj->textfield = 'lala\\';
$res = update_record($this->table, $obj);
$this->assertTrue($res);

$obj = get_record($this->table, 'textfield', 'lala\\');
$this->assertFalse(empty($obj));
}
} }


?> ?>

0 comments on commit 040bd93

Please sign in to comment.