-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved escaping to connection, better escapes for many types
- Loading branch information
Showing
11 changed files
with
376 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Database\MySql; | ||
|
||
use RuntimeException; | ||
|
||
/** | ||
* @requires extension pdo_mysql | ||
* @requires OS Linux|Darwin | ||
*/ | ||
class EscapeTest extends MySqlTestCase | ||
{ | ||
public function testEscapeInt() | ||
{ | ||
$this->assertSame('42', $this->app['db']->escape(42)); | ||
$this->assertSame('-6', $this->app['db']->escape(-6)); | ||
} | ||
|
||
public function testEscapeFloat() | ||
{ | ||
$this->assertSame('3.14159', $this->app['db']->escape(3.14159)); | ||
$this->assertSame('-3.14159', $this->app['db']->escape(-3.14159)); | ||
} | ||
|
||
public function testEscapeBool() | ||
{ | ||
$this->assertSame('1', $this->app['db']->escape(true)); | ||
$this->assertSame('0', $this->app['db']->escape(false)); | ||
} | ||
|
||
public function testEscapeBinary() | ||
{ | ||
$this->assertSame("x'dead00beef'", $this->app['db']->escape(hex2bin('dead00beef'), true)); | ||
} | ||
|
||
public function testEscapeString() | ||
{ | ||
$this->assertSame("'Hello\'World'", $this->app['db']->escape("Hello'World")); | ||
} | ||
|
||
public function testEscapeStringInvalidUtf8() | ||
{ | ||
$this->expectException(RuntimeException::class); | ||
|
||
$this->app['db']->escape("I am hiding an invalid \x80 utf-8 continuation byte"); | ||
} | ||
|
||
public function testEscapeStringNullByte() | ||
{ | ||
$this->expectException(RuntimeException::class); | ||
|
||
$this->app['db']->escape("I am hiding a \00 byte"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Database\Postgres; | ||
|
||
use RuntimeException; | ||
|
||
/** | ||
* @requires extension pdo_pgsql | ||
* @requires OS Linux|Darwin | ||
*/ | ||
class EscapeTest extends PostgresTestCase | ||
{ | ||
public function testEscapeInt() | ||
{ | ||
$this->assertSame('42', $this->app['db']->escape(42)); | ||
$this->assertSame('-6', $this->app['db']->escape(-6)); | ||
} | ||
|
||
public function testEscapeFloat() | ||
{ | ||
$this->assertSame('3.14159', $this->app['db']->escape(3.14159)); | ||
$this->assertSame('-3.14159', $this->app['db']->escape(-3.14159)); | ||
} | ||
|
||
public function testEscapeBool() | ||
{ | ||
$this->assertSame('true', $this->app['db']->escape(true)); | ||
$this->assertSame('false', $this->app['db']->escape(false)); | ||
} | ||
|
||
public function testEscapeBinary() | ||
{ | ||
$this->assertSame("'\\xdead00beef'::bytea", $this->app['db']->escape(hex2bin('dead00beef'), true)); | ||
} | ||
|
||
public function testEscapeString() | ||
{ | ||
$this->assertSame("'Hello''World'", $this->app['db']->escape("Hello'World")); | ||
} | ||
|
||
public function testEscapeStringInvalidUtf8() | ||
{ | ||
$this->expectException(RuntimeException::class); | ||
|
||
$this->app['db']->escape("I am hiding an invalid \x80 utf-8 continuation byte"); | ||
} | ||
|
||
public function testEscapeStringNullByte() | ||
{ | ||
$this->expectException(RuntimeException::class); | ||
|
||
$this->app['db']->escape("I am hiding a \00 byte"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Database\SqlServer; | ||
|
||
use RuntimeException; | ||
|
||
class EscapeTest extends SqlServerTestCase | ||
{ | ||
public function testEscapeInt() | ||
{ | ||
$this->assertSame('42', $this->app['db']->escape(42)); | ||
$this->assertSame('-6', $this->app['db']->escape(-6)); | ||
} | ||
|
||
public function testEscapeFloat() | ||
{ | ||
$this->assertSame('3.14159', $this->app['db']->escape(3.14159)); | ||
$this->assertSame('-3.14159', $this->app['db']->escape(-3.14159)); | ||
} | ||
|
||
public function testEscapeBool() | ||
{ | ||
$this->assertSame('1', $this->app['db']->escape(true)); | ||
$this->assertSame('0', $this->app['db']->escape(false)); | ||
} | ||
|
||
public function testEscapeBinary() | ||
{ | ||
$this->assertSame('0xdead00beef', $this->app['db']->escape(hex2bin('dead00beef'), true)); | ||
} | ||
|
||
public function testEscapeString() | ||
{ | ||
$this->assertSame("'Hello''World'", $this->app['db']->escape("Hello'World")); | ||
} | ||
|
||
public function testEscapeStringInvalidUtf8() | ||
{ | ||
$this->expectException(RuntimeException::class); | ||
|
||
$this->app['db']->escape("I am hiding an invalid \x80 utf-8 continuation byte"); | ||
} | ||
|
||
public function testEscapeStringNullByte() | ||
{ | ||
$this->expectException(RuntimeException::class); | ||
|
||
$this->app['db']->escape("I am hiding a \00 byte"); | ||
} | ||
} |
Oops, something went wrong.