Repository navigation
fix: pass the restore point description to its script as a parameter - #3236
Merged
Merged
Conversation
Restore Points wrote the description into the script that makes the point, inside single quotes with each ' doubled. PowerShell also ends a single-quoted string at the typographic quotes, so "Bob’s point" ended the string after "Bob", the script could not run, and no point was made. The description is now the script's Description parameter, as the other scripts take their values, and Preinstalled Apps' removal script takes the package name the same way. An architecture test fails any code that doubles quotes to put a value into a script's text.
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.
Restore Points could not make a point whose description held a typographic apostrophe.
What changes
RestorePointServicewrote the description into the script, inside single quotes with each'doubled. Windows PowerShell 5.1 also ends a single-quoted string at ‘ ’ ‚ ‛, which word processors and phone keyboards type for an apostrophe. Run through its parser, the old script for "Bob’s point" had three parse errors and its first string was "Bob".CreateScriptis now a constant that declaresparam([string]$Description), andCreateParameterspasses the description, or "SysManager Restore Point" when there is none, through the runner's parameters, as Defender, Task Scheduler and Scheduled Maintenance already do.RemoveScript,param([string]$Package)). The name was already checked againstPackageFullNameRegex, which admits no quote, and it still is.ArchitectureTests.NoScriptTakesAValue_ByDoublingItsQuotesfails any app code that doubles a quote withReplace, after showing that it finds the doubling as it was written.NoScriptParameter_IsNamedLikeAnAutomaticVariablenow counts 25 declared parameters, up from 23.Tests
RestorePointServiceTests:CreateAsyncpasses "Bob's point", "Bob’s point" and a description with all four typographic quotes as its only parameter, to the constant script.CreateParametersuses the default name for null, empty and blank. The script declares the parameter it passes toCheckpoint-Computer, and still stops on the daily-limit warning.DebloaterServiceTests: a removal sends the package name as thePackageparameter ofRemoveScript.RestorePointScriptTests(integration, real Windows PowerShell 5.1 with the cmdlets shadowed): the create script runs as a script block with-Description, as the runner binds it. A new case builds "Bob’s ‘p’ 'x" from its code points, and the stub reads back the same code points, followed by the success sentinel.Red checks
Each change below was put back on its own, and the named tests failed for that reason:
CreateAsyncpassing no description: all three rows ofCreateAsync_GivesTheScriptTheDescriptionAsItsParameter.CreateParameters_WithNoDescription_UseTheDefaultName.DebloaterService:NoScriptTakesAValue_ByDoublingItsQuotes, naming the file.CreateScript_TakesTheDescriptionItIsGiven, and in the integration suiteCreateScript_HandsCheckpointTheDescriptionWhole.Unit suite twice, the format check, and all four projects built with no warnings.