Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure allowed character set in QR code contents #254

Closed
sprain opened this issue Jun 19, 2024 · 2 comments · Fixed by #255
Closed

Ensure allowed character set in QR code contents #254

sprain opened this issue Jun 19, 2024 · 2 comments · Fixed by #255
Labels
bug Something isn't working

Comments

@sprain
Copy link
Owner

sprain commented Jun 19, 2024

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?

@sprain sprain added the bug Something isn't working label Jun 19, 2024
@sprain sprain changed the title Ensure allowed character sets in QR code contents Ensure allowed character set in QR code contents Jun 19, 2024
@kohlerdominik
Copy link
Contributor

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()?

@sprain
Copy link
Owner Author

sprain commented Jun 23, 2024

I prepared a solution for this in #255.
I tried to keep providing replacements for unsupported characters as simple as possible, as I imagine most devs will only want to replace a handful of characters, if any at all.

Anybody who likes to, is welcome to have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants