qrcode icon indicating copy to clipboard operation
qrcode copied to clipboard

generate_svg() failed when the input string contain '&'

Open kaveelim opened this issue 1 year ago • 3 comments

generate_svg() failed when the input string contain '&'.

library(qrcode)

qr_code("https://docs.google.com/forms/viewform?vc=0&c=0&w=1&flr=0", ecl = "H") |> 
  generate_svg("myqrcode.svg")

Created on 2024-02-09 with reprex v2.1.0

Here is the first few lines of myqrcode.svg.

<?xml version="1.0" encoding="UTF-8" ?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="300" width="300">
<g id="qrcode:https://docs.google.com/forms/viewform?vc=0&c=0&w=1&flr=0">

The problem seems to come from the <g id="..."> which contains '&'.

kaveelim avatar Feb 09 '24 01:02 kaveelim

I can confirm the bug. I'll look for a solution. I probably need to escape the & in the < g id> element.

ThierryO avatar Feb 09 '24 09:02 ThierryO

@kaveelim can you check this version of the package?

ThierryO avatar Mar 17 '24 13:03 ThierryO

@kaveelim can you check this version of the package?

Great!, I can confirm that it's working as expected. Thank you very much.

kaveelim avatar Mar 17 '24 14:03 kaveelim