Commit a78f404
committed
Make re-arm safe under Constrained Language Mode
Addresses Copilot review on PR #662.
__ShellInteg_Rearm compared prompt identity with [object]::ReferenceEquals.
Re-arm runs unconditionally at script load and from PSConsoleHostReadLine, and
under Constrained Language Mode a static method call is blocked. Confirmed:
Cannot invoke method. Method invocation is supported only on core types
in this language mode.
and the failure ABORTS the enclosing script even from inside try/catch, so it
would break profile sourcing or the input path. This is the same hazard the
script already guards elsewhere via $Global:__ShellInteg_CanInspectErrors.
Rather than no-op under Constrained Language Mode, identity is now compared
with -eq. ScriptBlock does not override Equals, so -eq IS reference identity
(verified: two scriptblocks with identical text compare False, the same object
compares True), and the operator is permitted in Constrained Language Mode.
Re-arming therefore keeps working there instead of being disabled.
Verified end-to-end under ConstrainedLanguage on Windows PowerShell 5.1 and
PowerShell 7: sourcing the script, rendering the prompt with marks, and the
input path all succeed with no exception. Note re-arm still has no per-command
driver in that mode because the PSConsoleHostReadLine wrapper is gated behind
CanInspectErrors - pre-existing v6 behaviour, unchanged here - so integration
degrades gracefully rather than self-healing.
Also fixes the repo's forbidden-spelling rule ('re-entrancy' -> 'reentrancy')
in the new tests, and adds an assertion that re-arm contains no static method
call at all, so this cannot regress.
104/104 ShellIntegrationTests pass.1 parent 1aad0a3 commit a78f404
2 files changed
Lines changed: 20 additions & 5 deletions
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
518 | | - | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
519 | 523 | | |
520 | 524 | | |
521 | 525 | | |
| |||
531 | 535 | | |
532 | 536 | | |
533 | 537 | | |
| 538 | + | |
| 539 | + | |
534 | 540 | | |
535 | 541 | | |
536 | 542 | | |
| |||
606 | 612 | | |
607 | 613 | | |
608 | 614 | | |
609 | | - | |
| 615 | + | |
610 | 616 | | |
611 | | - | |
| 617 | + | |
612 | 618 | | |
613 | 619 | | |
614 | 620 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
613 | 613 | | |
614 | 614 | | |
615 | 615 | | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
616 | 625 | | |
617 | 626 | | |
618 | | - | |
| 627 | + | |
619 | 628 | | |
620 | 629 | | |
621 | 630 | | |
622 | 631 | | |
623 | 632 | | |
624 | 633 | | |
625 | 634 | | |
626 | | - | |
| 635 | + | |
627 | 636 | | |
628 | 637 | | |
629 | 638 | | |
| |||
0 commit comments