2amigos / qrcode-library

Create QrCodes with ease
https://2am.tech/open-source/qrcode-generator
Other
222 stars 66 forks source link

Crashes if slash or colon is entered #46

Closed walker6o9 closed 1 year ago

walker6o9 commented 3 years ago

I'm trying to enter a website as the qrcode, something like google.com/test or https://google.com/test

When I do that, instead of a barcode I get:

���?n�h�

My code is pretty simple: public function actionQrcode($id = 1, $size = 100, $margin = 80) { $text = "www.google.com/test"; $qrCode = (new QrCode($text)) ->setSize($size) ->setMargin($margin) ->useForegroundColor(0, 0, 0) ->setLabel($id);

$image_path = Yii::$app->basePath . '/web/uploads/barcodes/';
if (!file_exists($image_path)) {
  mkdir($image_path, 0777, TRUE);
}
$qrCode->writeFile($image_path . $id . '.png'); // writer defaults to PNG when none is specified

// display directly to the browser header('Content-Type: ' . $qrCode->getContentType()); echo $qrCode->writeString(); }

tonydspaniard commented 3 years ago

hi @walker6o9 have you tried escaping the slash or use single quotes?

"https:\/\/google.com\/" 

or 

'https://google.com'
2amjsouza commented 1 year ago

no return from requester