Prerequisites
Steps to reproduce
Using 'Invoke-WebRequest -UseBasicParsing', the returned BasicHtmlWebResponseObject does not parse <input> tags correctly. It assumes they will be closed with a '/>' or '</input>'. However in html, neither the slash nor closing tag is required/legal depending on your html flavour.
The bug is in BasicHtmlWebResponseObject.Common.cs. The s_inputFieldRegex is set to:
@"<input\s+[^>]*(/>|>.*?</input>)"
But it should be:
@"<input\s+[^>]*(/>|>|>.*?</input>)"
Looking at the history the problem has been there since PowerShell 3.0, and remains unfixed in the latest PowerShell Core.
Expected behavior
Suppose we will perform an HTTP GET thusly:
`$response = Invoke-WebRequest -UseBasicParsing -Url 'https://localhost/test.html'`
And the returned html is:
`<html><body><input name='foo' value='mcgoo'></body>/</html>`
$response.InputFields should contain 1 element. $response.InputFields.FindByName('foo') should return the element.
Actual behavior
Instead $response.InputFields contains no elements, and $response.InputFields.FindByName('foo') returns $null.
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Prerequisites
Steps to reproduce
Using 'Invoke-WebRequest -UseBasicParsing', the returned BasicHtmlWebResponseObject does not parse <input> tags correctly. It assumes they will be closed with a '/>' or '</input>'. However in html, neither the slash nor closing tag is required/legal depending on your html flavour.
The bug is in BasicHtmlWebResponseObject.Common.cs. The s_inputFieldRegex is set to:
@"<input\s+[^>]*(/>|>.*?</input>)"But it should be:
@"<input\s+[^>]*(/>|>|>.*?</input>)"Looking at the history the problem has been there since PowerShell 3.0, and remains unfixed in the latest PowerShell Core.
Expected behavior
Actual behavior
Instead $response.InputFields contains no elements, and $response.InputFields.FindByName('foo') returns $null.Error details
No response
Environment data
Visuals
No response