Skip to content

fix: pass the restore point description to its script as a parameter - #3236

Merged
laurentiu021 merged 1 commit into
mainfrom
fix/restore-point-description-as-parameter
Nov 10, 2026
Merged

laurentiu021 merged 1 commit into
mainfrom
fix/restore-point-description-as-parameter

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

Restore Points could not make a point whose description held a typographic apostrophe.

What changes

  • The description is a parameter. RestorePointService wrote 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". CreateScript is now a constant that declares param([string]$Description), and CreateParameters passes the description, or "SysManager Restore Point" when there is none, through the runner's parameters, as Defender, Task Scheduler and Scheduled Maintenance already do.
  • Preinstalled Apps' removal script takes the package name the same way (RemoveScript, param([string]$Package)). The name was already checked against PackageFullNameRegex, which admits no quote, and it still is.
  • A guard for the class. ArchitectureTests.NoScriptTakesAValue_ByDoublingItsQuotes fails any app code that doubles a quote with Replace, after showing that it finds the doubling as it was written. NoScriptParameter_IsNamedLikeAnAutomaticVariable now counts 25 declared parameters, up from 23.

Tests

  • RestorePointServiceTests: CreateAsync passes "Bob's point", "Bob’s point" and a description with all four typographic quotes as its only parameter, to the constant script. CreateParameters uses the default name for null, empty and blank. The script declares the parameter it passes to Checkpoint-Computer, and still stops on the daily-limit warning.
  • DebloaterServiceTests: a removal sends the package name as the Package parameter of RemoveScript.
  • 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:

  • CreateAsync passing no description: all three rows of CreateAsync_GivesTheScriptTheDescriptionAsItsParameter.
  • A blank description kept instead of the default name: the empty and blank rows of CreateParameters_WithNoDescription_UseTheDefaultName.
  • The package name sent under another name: the removal test.
  • A quote doubled into a script again, in DebloaterService: NoScriptTakesAValue_ByDoublingItsQuotes, naming the file.
  • The script passing a fixed description instead of its parameter: CreateScript_TakesTheDescriptionItIsGiven, and in the integration suite CreateScript_HandsCheckpointTheDescriptionWhole.

Unit suite twice, the format check, and all four projects built with no warnings.

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.
@laurentiu021
laurentiu021 merged commit 698bc9b into main Nov 10, 2026
7 checks passed
@laurentiu021
laurentiu021 deleted the fix/restore-point-description-as-parameter branch November 10, 2026 10:26
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.

1 participant