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

util.c: add and use ascii-only char functions #5741

Merged
merged 2 commits into from
Mar 23, 2023

Conversation

kmk3
Copy link
Collaborator

@kmk3 kmk3 commented Mar 21, 2023

The "invalid_name" function claims to "allow strict ASCII letters and
numbers".

However, it uses isalnum(3) and isdigit(3), which may take the current
locale into account and thus return 1 for non-ASCII characters.

So add the following functions:

  • ascii_isalnum
  • ascii_isalpha
  • ascii_isdigit
  • ascii_islower
  • ascii_isupper
  • ascii_isxdigit

And use the applicable ones in "invalid_name" so that it actually uses
strictly ASCII in its comparisons.

Added on commit b4ffaa2 ("merges; more on cleaning up esc chars",
2023-02-14).

Relates to #5578.

Kind of relates to #5708.

@kmk3 kmk3 requested a review from netblue30 March 21, 2023 00:48
@kmk3 kmk3 added this to In progress in Release 0.9.74 via automation Mar 21, 2023
@kmk3
Copy link
Collaborator Author

kmk3 commented Mar 21, 2023

Misc: There are also improvements for #5708 which depend on this PR.

@kmk3
Copy link
Collaborator Author

kmk3 commented Mar 21, 2023

(Rebased to master to fix CI checks)

Follow the same order as on util.c.

Added on commit b4ffaa2 ("merges; more on cleaning up esc chars",
2023-02-14).
The "invalid_name" function claims to "allow strict ASCII letters and
numbers".

However, it uses isalnum(3) and isdigit(3), which may take the current
locale into account and thus return 1 for non-ASCII characters.

So add the following functions:

* ascii_isalnum
* ascii_isalpha
* ascii_isdigit
* ascii_islower
* ascii_isupper
* ascii_isxdigit

And use the applicable ones in "invalid_name" so that it actually uses
strictly ASCII in its comparisons.

Added on commit b4ffaa2 ("merges; more on cleaning up esc chars",
2023-02-14).

Relates to netblue30#5578.

Kind of relates to netblue30#5708.
@netblue30 netblue30 merged commit 9beed35 into netblue30:master Mar 23, 2023
@netblue30
Copy link
Owner

Nice, thanks!

@kmk3 kmk3 deleted the util-ascii-char-fns branch March 24, 2023 06:02
kmk3 added a commit that referenced this pull request Jun 19, 2023
@kmk3 kmk3 moved this from In progress to Done (on RELNOTES) in Release 0.9.74 Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Release 0.9.74
  
Done (on RELNOTES)
Development

Successfully merging this pull request may close these issues.

None yet

2 participants