rdoeffinger / iec16022

DataMatrix 2D barcode generator

Home Page:http://rdoeffinger.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Barcode with newlines creates unreadable Stamp and Eps images

geusebi opened this issue · comments

The comment %%BarcodeData cause Eps and Stamp images to be unreadable because the data is leaking out of comments boundaries

iec16022 -s 104x104 -f Eps -i <(printf "line1\nline2\nline3") | sed -n 2,7p
%%Creator: IEC16022 barcode/stamp generator
%%BarcodeData: line 1
line 2
line 3
%%BarcodeSize: 104x104
%%BarcodeFormat: ECC200

The barcode should be properly escaped or split over multiple lines, e.g.:

iec16022 -s 104x104 -f Eps -i <(printf "line1\nline2\nline3") | sed -n 2,5p
%%Creator: IEC16022 barcode/stamp generator
%%BarcodeData: line1\nline2\nline3
%%BarcodeSize: 104x104
%%BarcodeFormat: ECC200

Sorry, I had missed this somehow.
It seems a bit overkill to me for just a comment, wouldn't it be reasonable to just replace anything problematic with a space instead for much simpler code?

To me it's reasonable enough as long as the resulting EPS is valid and readable.
I wrote the code this way just to stick to the language reference.
Replacing \n and \f with spaces is a good compromise.

I can update the PR tomorrow if you want me to.

Thanks for the offer, but I pushed my own version of it in commit 712ca1d
I thought it safest to remove all control characters, and to do it in a way that also works for the other output formats like PNG.
I actually meant to credit you in the commit message for finding it and proposing the original solution but forgot in the end, sorry.
Great if you can test it.
Re-open if there's any issue/concern with it.

I'll test it during the weekend but it already looks good to me.
Many thanks for your work and for thinking to credit me, no problem if you forgot. That's still a nice gesture