[WIP] Undefined variable value yields '.' as node and may cause removing all files in tree.#3905
Open
bdbaddog wants to merge 3 commits intoSCons:masterfrom
Open
[WIP] Undefined variable value yields '.' as node and may cause removing all files in tree.#3905bdbaddog wants to merge 3 commits intoSCons:masterfrom
bdbaddog wants to merge 3 commits intoSCons:masterfrom
Conversation
… cause rermoving all files in tree.
mwichmann
reviewed
Mar 22, 2021
| global CleanTargets | ||
|
|
||
| # Check for anything which evaluates to empty string, which would yield cleaning '.' | ||
| targets_strings = [(t, self.subst(t)) for t in flatten(targets) if is_String(t) and ('$' in t or t == '')] |
Collaborator
There was a problem hiding this comment.
wouldn't it be simpler to just let tlist and flist expand and check in them?
Contributor
Author
There was a problem hiding this comment.
So I don't think using tlist or flist would allow proper checking for accidental '.' from undefined var.
Also you wouldn't be able to give as much information about what was wrong.
mwichmann
reviewed
Mar 22, 2021
mwichmann
reviewed
Mar 22, 2021
mwichmann
reviewed
Jun 22, 2022
| raise UserError( | ||
| "Targets specified to Clean() include one which evaluates to an empty string: [%s]" % ",".join( | ||
| ["%s='%s'" % (str(t), s) for (t, s) in targets_strings])) | ||
| if any([s == '' for t, s in files_strings]): |
Collaborator
There was a problem hiding this comment.
I see that one stanza checks targets_strings and the other files_strings, but this still reads quite duplicative... any way to combine?
Collaborator
|
Attaching a test case made from the original report (suffixed .txt instead of .py due to github limitations) |
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.
Fixes #2801. Undefined variable value yields '.' as node and may cause removing all files in tree.
Contributor Checklist:
CHANGES.txt(and read theREADME.rst)