Repository navigation
Fix: Anchor blocklist patterns to prevent false positives in file check - #506
Open
CookieDarb wants to merge 1 commit into
Open
CookieDarb wants to merge 1 commit into
CookieDarb wants to merge 1 commit into
Conversation
|
I checked I also checked all seven blocked extensions in lowercase and uppercase, the three XML allowlist names, and That’s 24 cases checked against each version. This was an isolated call to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #504
Fixes false-positive
REQUIREDerrors inFile_Checkby anchoring file extension patterns in the blocklist to the end of the filename.Why?
File_Checkmatches its blocklist usingpreg_grep( '/' . $file . '/', $filenames ).Because extension patterns like
\.sh,\.dat, and\.sqllacked end-of-string anchors ($), the regex matched those characters anywhere in the path. This caused ordinary CSS, JS, and data files (such as Material Design token stylesheets liketokens.sys.shape.css, modular scripts liketheme.shortcodes.js, and data files likesample.data.json) to be incorrectly flagged as shell scripts, customizer import files, or SQL dumps. Since these checks raise aREQUIREDerror, themes with valid assets failed automated Theme Check scans.How?
checks/class-file-check.php:$) to all file extension patterns in$blocklist(\.sh$,\.sql$,\.dat$,\.xml$,\.wie$,\.kpf$,\.lubith$).thumbs\.db,desktop\.ini,error_log,__MACOSX,^\.+[a-zA-Z0-9]) untouched.Testing Instructions
assets/styles/tokens.sys.shape.cssassets/js/theme.shortcodes.jsassets/data/sample.data.jsonassets/data/db.sqlite3deploy.shbackup.sqlexport.dattokens.sys.shape.css,theme.shortcodes.js,sample.data.json,db.sqlite3) pass without false positives.deploy.sh,backup.sql,export.dat) are still correctly flagged withREQUIREDerrors.Use of AI Tools
AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini
Used for: Reviewing the existing regex patterns and drafting test files. Final code and testing were done by me.