kreativekorp / barcode

barcode.php - Generate barcodes from a single PHP file. MIT license.
MIT License
257 stars 135 forks source link

Can't pass "&" in dmtx or qr #20

Open aculine opened 3 years ago

aculine commented 3 years ago

Hi, I cannot be able to pass url with & in barcode dmtx or qr. If I use %26 (& in urlencode), barcode seams do not draw correcly. I need to pass a url like "https://www.domain.ext/wp-admin/post.php?action=edit&post=123"

Any idea?

Thank you, Luca

merry-goblin commented 9 months ago

This library allows to build and display a barcode by calling it directly from your browser. If it seems like a fancy and easy way to produce a barcode. Actually it is a very bad idea. It allows other people than yourself to call build their own barcodes with your code. This is absurd.

You should instead build your barcode from your own script like below. It will also solve your problem.

<?php

require_once('barcode.php');

$generator = new barcode_generator();
$data = 'https://www.domain.ext/wp-admin/post.php?action=edit&post=123';
$format = 'png';
$type = 'qr';
$options = [
    'w' => 600,
    'h' => 600,
];
$generator->output_image($format , $type, $data, $options);