Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug when pasting multiple line in the console #5143

Open
3 of 6 tasks
I-am-Victor opened this issue Feb 20, 2025 · 3 comments
Open
3 of 6 tasks

bug when pasting multiple line in the console #5143

I-am-Victor opened this issue Feb 20, 2025 · 3 comments
Labels
Issue-Bug A bug to squash. Needs: Author Feedback Please give us the requested feedback!

Comments

@I-am-Victor
Copy link

I-am-Victor commented Feb 20, 2025

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

if i paste my input into my script, it shows error.
however, if i type them line by line, there wont be any error and runs smoothly.
this only happens in debugging(set breakpoints).

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Microsoft Windows 10.0.26120
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Name             : ConsoleHost
Version          : 7.5.0
InstanceId       : f39c9f54-ffe9-4734-9ad8-35fbc958b513
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : zh-CN
CurrentUICulture : zh-CN
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

PS C:\Users\Victor\Other\Apps> code --version
1.97.2
e54c774e0add60467559eb0d1e229c6452cf8447
x64

Extension Version

PS C:\Users\Victor\Other\Apps> code --list-extensions --show-versions | Select-String powershell

[email protected]

Steps to Reproduce

[string[]]$domains = $null
while ($true) {
    $inp = Read-Host
    if ([string]::IsNullOrEmpty($inp)) {
        break
    }
    $domains += $inp
}
[string]$rules = "--host-rules="""
[string]$resolver = "--host-resolver-rules="""
for ($i = 0; $i -lt $domains.Count; $i++) {
    [string]$check = q.exe $domains[$i] A `@https://dns.quad9.net
    [string]$ip = ($check.Split() | Select-String -Pattern "\d{1,}\.\d{1,}\.\d{1,}\.\d{1,}")[0]
    if (-not $i -eq 0) {
        $rules += ","
        $resolver += ","
    }
    $rules += "MAP *$($domains[$i]) url$i"
    $resolver += "MAP url$i $ip"
}
$rules += """"
$resolver += """"
start-process "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" -ArgumentList "$rules $resolver --test-type --ignore-certificate-errors"

input: (pasting)

github.com                                   
pixiv.net 
exhentai.org

error:

InvalidOperation: C:\Users\Victor\Other\Programs\Scripts\sni.ps1:13:5
Line |
  13 |      [string]$ip = ($check.Split() | Select-String -Pattern "\d{1,}\.\ …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot index into a null array.
InvalidOperation: C:\Users\Victor\Other\Programs\Scripts\sni.ps1:13:5
Line |
  13 |      [string]$ip = ($check.Split() | Select-String -Pattern "\d{1,}\.\ …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot index into a null array.

P.S. q.exe is [https://github.com/natesales/q]

Visuals

[https://1drv.ms/v/c/77c324b406508168/EZgTrStUAfpGuZO3bA6n7hEBSzeS999JyAEuSPnbfG05gg]

Logs

No response

@I-am-Victor I-am-Victor added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Feb 20, 2025
@andyleejordan
Copy link
Member

Hi, sorry about this, do you have viable workaround? I think we'd need a more minimal reproduction to figure out this bug.

@andyleejordan andyleejordan added Needs: Author Feedback Please give us the requested feedback! and removed Needs: Triage Maintainer attention needed! labels Feb 25, 2025
@I-am-Victor
Copy link
Author

bugs.txt

[string[]]$domains = $null
while ($true) {
    $inp = Read-Host
    if ([string]::IsNullOrEmpty($inp)) {
        break
    }
    $domains += $inp
} #stop until a blank line.
for ($i = 0; $i -lt $domains.Count; $i++) {
    [string]$check = q.exe $domains[$i] A `@tls://dns.google
    Write-Output $check;
}

If you copy bugs.txt and paste it in the script, the error shows.
This is the console shows when debugging:

PS C:\Users\Victor\Other\Programs> Write-Host "**$($domains[$i])**"
**github.com                                   **
PS C:\Users\Victor\Other\Programs> q.exe $domains[$i] A `@tls://dns.google
PS C:\Users\Victor\Other\Programs> q.exe github.com                                    A `@tls://dns.google
github.com. 1m A 20.205.243.166

@github-actions github-actions bot added Needs: Maintainer Attention Maintainer attention needed! and removed Needs: Author Feedback Please give us the requested feedback! labels Mar 2, 2025
@JustinGrote
Copy link
Collaborator

JustinGrote commented Mar 2, 2025

paste it in the script
can you be more specific? I can't reproduce, pasting into the PSES terminal works just fine for me.

20250302-1658-51.7938773.mp4

@JustinGrote JustinGrote added Needs: Author Feedback Please give us the requested feedback! and removed Needs: Maintainer Attention Maintainer attention needed! labels Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash. Needs: Author Feedback Please give us the requested feedback!
Projects
None yet
Development

No branches or pull requests

3 participants