Fix config.py --help when the current directory contains a percent character #162

Open
gilles-peskine-arm wants to merge 1 commit from gilles-peskine-arm/config-py-help-directory-percent-framework into main
gilles-peskine-arm commented 2025-04-16 08:51:16 -05:00 (Migrated from github.com)

Fix config.py --help raising an exception (or otherwise misbehaving, in rare cases) when the current working directory contains a percent character. This was due to a percent escape bug.

To check for similar issues, I used the following code, which searches in all Python files for help="...".format or help="..."% or help="...%...", allowing for different quote characters.

git ls-files --recurse-submodules '*.py' | xargs perl -000 -ne 'while (/(help=("""|"(?!")|\x27\x27\x27|\x27(?!\x27))(.*?)\2\s*(\.format|%)?)/sg) { printf "%s:%d:%s\n\n", $ARGV, $., $1 if defined $4 or $2 =~ /%/ } }continue{ close ARGV if eof'

PR checklist

  • TF-PSA-Crypto PR not required because: no problem found in crypto
  • development PR TODO (but can be done independently)
  • 3.6 PR provided
Fix `config.py --help` raising an exception (or otherwise misbehaving, in rare cases) when the current working directory contains a percent character. This was due to a percent escape bug. To check for similar issues, I used the following code, which searches in all Python files for `help="...".format` or `help="..."%` or `help="...%..."`, allowing for different quote characters. ``` git ls-files --recurse-submodules '*.py' | xargs perl -000 -ne 'while (/(help=("""|"(?!")|\x27\x27\x27|\x27(?!\x27))(.*?)\2\s*(\.format|%)?)/sg) { printf "%s:%d:%s\n\n", $ARGV, $., $1 if defined $4 or $2 =~ /%/ } }continue{ close ARGV if eof' ``` ## PR checklist - [x] **TF-PSA-Crypto PR** not required because: no problem found in crypto - [ ] **development PR** TODO (but can be done independently) - [x] **3.6 PR** provided
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'gilles-peskine-arm/config-py-help-directory-percent-framework:gilles-peskine-arm/config-py-help-directory-percent-framework'
git switch 'gilles-peskine-arm/config-py-help-directory-percent-framework'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'gilles-peskine-arm/config-py-help-directory-percent-framework'
git switch 'gilles-peskine-arm/config-py-help-directory-percent-framework'
git rebase 'main'
git switch 'main'
git merge --ff-only 'gilles-peskine-arm/config-py-help-directory-percent-framework'
git switch 'gilles-peskine-arm/config-py-help-directory-percent-framework'
git rebase 'main'
git switch 'main'
git merge --no-ff 'gilles-peskine-arm/config-py-help-directory-percent-framework'
git switch 'main'
git merge --squash 'gilles-peskine-arm/config-py-help-directory-percent-framework'
git switch 'main'
git merge --ff-only 'gilles-peskine-arm/config-py-help-directory-percent-framework'
git switch 'main'
git merge 'gilles-peskine-arm/config-py-help-directory-percent-framework'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-Mbed-TLS/mbedtls-framework!162
No description provided.