Skip to content

Quote file paths in regex matches. - #3248

Open
somiaj wants to merge 1 commit into
openwebwork:developfrom
somiaj:quote-regex-files
Open

somiaj wants to merge 1 commit into
openwebwork:developfrom
somiaj:quote-regex-files

Conversation

@somiaj

@somiaj somiaj commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

File paths can contain special regex characters such as ".", "+", "(", ")", etc. Most paths are configured at the server level and since "." is a wild card it has worked. A few paths contain file names created by a user, so these could possibly break the regex match or match the wrong thing.

Quote all instances of paths which are not meant to be regex with \Q$var\E, which will prevent treating special characters as regex.

Clarify the extra_headers and extra_ssl_headers urls are used as regex strings to match the path in conf/webwork2.mojolicious.dist.yml.

Two new ^ anchors were also added for matching the prefix of a path in SampleProblemViewer.pm and CourseActions.pm.

The AchievementEditor and AchievementNotificationEditor were left alone since I'm working on those in a separate PR.

Comment thread lib/Mojolicious/WeBWorK.pm Outdated
File paths can contain special regex characters such as
".", "+", "(", ")", etc. Most paths are configured at the
server level and since "." is a wild card it has worked.
A few paths contain file names created by a user, so these
could possibly break the regex match or match the wrong thing.

Quote all instances of paths which are not meant to be regex
with `\Q$var\E`, which will prevent treating special characters
as regex.

Clarify the extra_headers and extra_ssl_headers urls are used as
regex strings to match the path in conf/webwork2.mojolicious.dist.yml.

Two new `^` anchors were also added for matching the prefix
of a path in SampleProblemViewer.pm and CourseActions.pm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@somiaj
somiaj force-pushed the quote-regex-files branch from 6267b7f to 47bcede Compare October 23, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants