Ensure allowed character set in QR code contents
Closed this issue · 2 comments
The characters «
and »
are very common in Switzerland, but are not allowed within qr code contents.
Here is an example from the validator, giving the regex to check against:
Error: value 'Verein «Beispielname»' does not match regular expression facet '([a-zA-Z0-9\.,;:'\+\-/\(\)?\*\[\]\{\}\|\\`´~ ]|[!"#%&<>÷=@_$£^]|[àáâäçèéêëìíîïñòóôöùúûüýßÀÁÂÄÇÈÉÊËÌÍÎÏÒÓÔÖÙÚÛÜÑ])*'
To consider: Do we want to implement some auto-replacement for invalid characters within the library to make string handling as easy as possible for developers?
Hi sprain
My 2 cents:
Instead of throwing an exception, just striping the chars seems more developer-friendly to me (= replace with empty string).
If developers wants specific replacement characters, they can replace them before passing the string to the library. Bonus points if this replcement function is part of the public package API, so they can use it as well and maybe pass a callback to it (like preg_replace_callback()
?