From 788fc0780e0fd601c21dafd9e364e590c7cff15c Mon Sep 17 00:00:00 2001 From: Bostjan Rihter Date: Sun, 11 Mar 2018 00:19:08 +0100 Subject: [PATCH 1/3] Removed trim() from QRCode->getMatrix(). Data sanitization should be done outside. --- src/QRCode.php | 3 ++- tests/QRCodeTest.php | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/QRCode.php mode change 100644 => 100755 tests/QRCodeTest.php diff --git a/src/QRCode.php b/src/QRCode.php old mode 100644 new mode 100755 index 96598218b..444c88b8b --- a/src/QRCode.php +++ b/src/QRCode.php @@ -161,7 +161,8 @@ class QRCode{ * @throws \chillerlan\QRCode\Data\QRCodeDataException */ public function getMatrix(string $data):QRMatrix { - $data = trim($data); + //NOTE: data sanitation should be done outside + //$data = trim($data); if(empty($data)){ throw new QRCodeDataException('QRCode::getMatrix() No data given.'); diff --git a/tests/QRCodeTest.php b/tests/QRCodeTest.php old mode 100644 new mode 100755 index c9430bc8e..ccfa5eb7c --- a/tests/QRCodeTest.php +++ b/tests/QRCodeTest.php @@ -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'])]); From ab2ad321fd4d2fd455ec8416cedaf723d5c75dea Mon Sep 17 00:00:00 2001 From: Bostjan Rihter Date: Sun, 11 Mar 2018 00:26:46 +0100 Subject: [PATCH 2/3] Indentation. --- src/QRCode.php | 5 ++--- tests/QRCodeTest.php | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/QRCode.php b/src/QRCode.php index 444c88b8b..d7ec8abb1 100755 --- a/src/QRCode.php +++ b/src/QRCode.php @@ -161,9 +161,8 @@ class QRCode{ * @throws \chillerlan\QRCode\Data\QRCodeDataException */ public function getMatrix(string $data):QRMatrix { - //NOTE: data sanitation should be done outside - //$data = trim($data); - + //NOTE: input sanitization should be done outside + //$data = trim($data); if(empty($data)){ throw new QRCodeDataException('QRCode::getMatrix() No data given.'); } diff --git a/tests/QRCodeTest.php b/tests/QRCodeTest.php index ccfa5eb7c..edeb9569a 100755 --- a/tests/QRCodeTest.php +++ b/tests/QRCodeTest.php @@ -94,12 +94,12 @@ class QRCodeTest extends QRTestAbstract{ $this->qrcode->getMatrix(''); } - public function testTrim() { - $m1 = $this->qrcode->getMatrix('hello'); - $m2 = $this->qrcode->getMatrix('hello '); // added space + public function testTrim() { + $m1 = $this->qrcode->getMatrix('hello'); + $m2 = $this->qrcode->getMatrix('hello '); // added space - $this->assertNotEquals($m1, $m2); - } + $this->assertNotEquals($m1, $m2); + } public function testImageTransparencyBGDefault(){ $this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['imageTransparencyBG' => 'foo'])]); From a08d080d96d0f1756a96d8401f2b7a99735015b5 Mon Sep 17 00:00:00 2001 From: Bostjan Rihter Date: Sun, 11 Mar 2018 00:29:05 +0100 Subject: [PATCH 3/3] Tabs. --- src/QRCode.php | 5 +++-- tests/QRCodeTest.php | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/QRCode.php b/src/QRCode.php index d7ec8abb1..625d994bf 100755 --- a/src/QRCode.php +++ b/src/QRCode.php @@ -161,8 +161,9 @@ class QRCode{ * @throws \chillerlan\QRCode\Data\QRCodeDataException */ public function getMatrix(string $data):QRMatrix { - //NOTE: input sanitization should be done outside - //$data = trim($data); + //NOTE: input sanitization should be done outside + //$data = trim($data); + if(empty($data)){ throw new QRCodeDataException('QRCode::getMatrix() No data given.'); } diff --git a/tests/QRCodeTest.php b/tests/QRCodeTest.php index edeb9569a..046715240 100755 --- a/tests/QRCodeTest.php +++ b/tests/QRCodeTest.php @@ -94,12 +94,12 @@ class QRCodeTest extends QRTestAbstract{ $this->qrcode->getMatrix(''); } - public function testTrim() { - $m1 = $this->qrcode->getMatrix('hello'); - $m2 = $this->qrcode->getMatrix('hello '); // added space + public function testTrim() { + $m1 = $this->qrcode->getMatrix('hello'); + $m2 = $this->qrcode->getMatrix('hello '); // added space - $this->assertNotEquals($m1, $m2); - } + $this->assertNotEquals($m1, $m2); + } public function testImageTransparencyBGDefault(){ $this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['imageTransparencyBG' => 'foo'])]);