From df3067306e5622fdece5f3b73188979d9b335468 Mon Sep 17 00:00:00 2001 From: Colin Cogle <19931245+rhymeswithmogul@users.noreply.github.com> Date: Wed, 29 Jun 2022 21:40:54 -0400 Subject: [PATCH] Fix query string parsing bug. With some specially-formatted URLs, query strings would be sent to the server even when they didn't exist. This has been corrected by not only checking for $null, but for string length. Surprisingly, I wasn't able to reproduce this on all versions of PowerShell that this module supports. --- COPYING | 6 +++++- NEWS | 4 ++++ PSGopher.psd1 | 4 ++-- src/PSGopher.psm1 | 5 ++++- 4 files changed, 15 insertions(+), 4 deletions(-) mode change 120000 => 100644 COPYING diff --git a/COPYING b/COPYING deleted file mode 120000 index 7a694c9..0000000 --- a/COPYING +++ /dev/null @@ -1 +0,0 @@ -LICENSE \ No newline at end of file diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..1f1ddd9 --- /dev/null +++ b/COPYING @@ -0,0 +1,5 @@ +XSym +0007 +9879d6db96fd29134fc802214163b95a +LICENSE + \ No newline at end of file diff --git a/NEWS b/NEWS index e819030..8c22b2f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +VERSION 1.1.1 +- Fixes a bug where query strings might be erroneously detected and sent + to the server, causing resource lookups to fail. + VERSION 1.1 - Adds support for Gopher query strings via the $InputObject parameter. Previously, one would have to form their own URL with a query string. diff --git a/PSGopher.psd1 b/PSGopher.psd1 index 64511ba..d48f914 100644 --- a/PSGopher.psd1 +++ b/PSGopher.psd1 @@ -9,7 +9,7 @@ RootModule = 'src/PSGopher.psm1' # Version number of this module. -ModuleVersion = '1.1.0' +ModuleVersion = '1.1.1' # Supported PSEditions CompatiblePSEditions = @('Core', 'Desktop') @@ -80,7 +80,7 @@ PrivateData = @{ # IconUri = '' # ReleaseNotes of this module - ReleaseNotes = 'This version supports query strings.' + ReleaseNotes = 'This version supports query strings properly.' # Prerelease string of this module # Prerelease = '' diff --git a/src/PSGopher.psm1 b/src/PSGopher.psm1 index a507f44..a6691e6 100644 --- a/src/PSGopher.psm1 +++ b/src/PSGopher.psm1 @@ -102,7 +102,10 @@ Function Invoke-GopherRequest { #endregion (Content type negotiation) #region Parse input parameters - If ($null -ne $InputObject) { + If ($null -eq $InputObject -or $InputObject.Length -eq 0) { + Write-Debug 'No query string detected.' + } + Else { Write-Debug "Found query string=$InputObject" $Encoder = [Web.HttpUtility]::ParseQueryString('')