Skip to content

WiP: switch e.g. html/javascript template strings with embedded escape codes to raw string - #395

Draft
jonasbardino wants to merge 10 commits into
nextfrom
fix/invalid-escape-sequences-in-strings-with-explicit-raw-strings
Draft

WiP: switch e.g. html/javascript template strings with embedded escape codes to raw string#395
jonasbardino wants to merge 10 commits into
nextfrom
fix/invalid-escape-sequences-in-strings-with-explicit-raw-strings

Conversation

@jonasbardino

@jonasbardino jonasbardino commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

Switch e.g. html/javascript template strings with embedded escapes in them to raw strings like r"bla\*" in order to avoid DeprecationWarning(on python3.6+) orSyntaxError` (python3.12+).

Tools like bandit will warn about the existence of such strings when scanned so it can be used to locate all relevant occurrences in our code base.

It's important to validate that the raw string wrapping does not change the meaning of the code. They typically remove the need for one level of escaping as in

 > python
Python 3.12.3 (main, Nov  6 2025, 13:44:16) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> r'\.'
'\\.'

Integrates #609 to prevent the corresponding old lint errors in existing code. So it's best to merge that one first.

Still pending some verification that none of the updates actually change the resulting strings. Manually verified for server/*.py and shared/functionality/*.py modules so far.

We should add unit tests to verify the correct output of the individual functions or the entire page. Since it overlaps with #612, #613 and #614 it may be best to merge those first and rebase here.

@jonasbardino jonasbardino self-assigned this Dec 12, 2025
@jonasbardino jonasbardino added the WiP Work-in-Progress: any review requests do NOT mean it's ready for merge. label Jul 2, 2026
…scapes in

them to raw strings in order to avoid DeprecationWarning (on python3.6+) or
SyntaxError (python3.12+).
@jonasbardino
jonasbardino force-pushed the fix/invalid-escape-sequences-in-strings-with-explicit-raw-strings branch from 0fcccff to 5d7a987 Compare July 17, 2026 12:34
…rings to

avoid DeprecationWarning or SyntaxError when running our code or the unit tests
with recent python versions.
Now `make unittest` completes without such issues. There may be additional
cases lurking in parts of the code simply not covered by unittests yet.
…s are

used. Now checking with
`bandit -v -r mig/shared|grep 'invalid escape sequence'`
only reports an invalid escaped '\S' in the ancient `forum.py` helper which is
scheduled for retirement.
…s are

used in `mig/server/` as well . Now checking with
`bandit -v -r mig/|grep 'invalid escape sequence'`
only reports an invalid escaped '\S' in the ancient `forum.py` helper which is
scheduled for retirement.
Reimplemented the dead-ugly conditional print in `print_on_error` in an attempt
to prevent any future readers from going insane.
@jonasbardino

Copy link
Copy Markdown
Contributor Author

The final remaining lint error is a duplicate of the old one from #338.

…eparate

future branch. It is also necessary to introduce the now mandatory parenteses
currently missing in the old (py2) print statements.
…leaving

out the complex escaping to completely remove the need for r-strings there.

Further updates may be needed there as well in the future task to fix the
py2'isms like `print "bla"` without parentheses in the python version.
… and

explicitly check that the r-string modification doesn't change anything.
I tested with and without the r-string change enabled to confirm.
jonasbardino added a commit that referenced this pull request Jul 21, 2026
…s visited

in #395 to help verify correctness there.
Rework the functionality backend `main` functions to follow the wrapping used
in `datatransfer` and its tests. Not optimal but needed unless we reimplement
`main` everywhere :-/

Exposed `path_info` arg in the shared `create_http_environ` helper in order to
let other helpers extract the active backend from that field in env when used.

Added missing check for enabled workflows in vgridworkflows and adjusted to
make sure the title dictionary it appends to has the expected 'advanced',
'init' and 'ready' fields.

Automatic style polish from editor and autopep8 in some locations.
@jonasbardino jonasbardino added the stale check errors Linting/CI errors are stale old issues not caused by this PR and will be fixed elsewhere. label Jul 23, 2026
jonasbardino added a commit that referenced this pull request Jul 30, 2026
…olish (#609)

* Address a few lint errors including the one highlighted in #395 and polish to
be more robust even if an invalid path type is given.

* Address review feedback (thanks @Martin-Rehr):
Reworked handling of missing paths to avoid corner-case changes of logic and
warn about unsupported type answers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale check errors Linting/CI errors are stale old issues not caused by this PR and will be fixed elsewhere. WiP Work-in-Progress: any review requests do NOT mean it's ready for merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant