Skip to content
Browse files

MDL-29033 add tests for the sql injection hack

  • Loading branch information...
1 parent bf0ddcb commit 040bd939b267f170c71239193d4d3ab489b5a4ca @skodak skodak committed Sep 9, 2011
Showing with 17 additions and 0 deletions.
  1. +17 −0 lib/simpletest/testdmllib.php
View
17 lib/simpletest/testdmllib.php
@@ -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.
Something went wrong with that request. Please try again.