qrcode-library icon indicating copy to clipboard operation
qrcode-library copied to clipboard

Crashes if slash or colon is entered

Open walker6o9 opened this issue 4 years ago • 1 comments

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(); }

walker6o9 avatar Jan 20 '21 01:01 walker6o9

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

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

or 

'https://google.com'

tonydspaniard avatar Feb 10 '21 05:02 tonydspaniard

no return from requester

2amjsouza avatar Oct 07 '23 04:10 2amjsouza