Merge pull request #15 from wickedsheep/fix_input_trim

Fix input trim
This commit is contained in:
smiley
2018-03-13 17:23:52 +01:00
committed by GitHub
2 changed files with 10 additions and 2 deletions
Regular → Executable
+3 -2
View File
@@ -161,8 +161,9 @@ class QRCode{
* @throws \chillerlan\QRCode\Data\QRCodeDataException
*/
public function getMatrix(string $data):QRMatrix {
$data = trim($data);
//NOTE: input sanitization should be done outside
//$data = trim($data);
if(empty($data)){
throw new QRCodeDataException('QRCode::getMatrix() No data given.');
}
Regular → Executable
+7
View File
@@ -94,6 +94,13 @@ class QRCodeTest extends QRTestAbstract{
$this->qrcode->getMatrix('');
}
public function testTrim() {
$m1 = $this->qrcode->getMatrix('hello');
$m2 = $this->qrcode->getMatrix('hello '); // added space
$this->assertNotEquals($m1, $m2);
}
public function testImageTransparencyBGDefault(){
$this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['imageTransparencyBG' => 'foo'])]);