Title: BasicHtmlWebResponseObject does not parse self-closing tags · Issue #16126 · PowerShell/PowerShell · GitHub
Open Graph Title: BasicHtmlWebResponseObject does not parse self-closing tags · Issue #16126 · PowerShell/PowerShell
X Title: BasicHtmlWebResponseObject does not parse self-closing tags · Issue #16126 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/16126
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"BasicHtmlWebResponseObject does not parse self-closing \u003cinput> tags","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://docs.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\nUsing 'Invoke-WebRequest -UseBasicParsing', the returned BasicHtmlWebResponseObject does not parse \\\u003cinput\\> tags correctly. It assumes they will be closed with a '/\\>' or '\\\u003c/input\\>'. However in html, neither the slash nor closing tag is required/legal depending on your html flavour.\r\n\r\nThe bug is in BasicHtmlWebResponseObject.Common.cs. The s_inputFieldRegex is set to:\r\n\r\n`@\"\u003cinput\\s+[^>]*(/>|>.*?\u003c/input>)\"`\r\n\r\nBut it should be:\r\n\r\n`@\"\u003cinput\\s+[^>]*(/>|>|>.*?\u003c/input>)\"`\r\n\r\nLooking at the history the problem has been there since PowerShell 3.0, and remains unfixed in the latest PowerShell Core.\r\n\r\n### Expected behavior\r\n\r\n```console\r\nSuppose we will perform an HTTP GET thusly:\r\n\r\n`$response = Invoke-WebRequest -UseBasicParsing -Url 'https://localhost/test.html'`\r\n\r\nAnd the returned html is:\r\n\r\n`\u003chtml>\u003cbody>\u003cinput name='foo' value='mcgoo'>\u003c/body>/\u003c/html>`\r\n\r\n$response.InputFields should contain 1 element. $response.InputFields.FindByName('foo') should return the element.\r\n```\r\n\r\n\r\n### Actual behavior\r\n\r\n```console\r\nInstead $response.InputFields contains no elements, and $response.InputFields.FindByName('foo') returns $null.\r\n```\r\n\r\n\r\n### Error details\r\n\r\n_No response_\r\n\r\n### Environment data\r\n\r\n```powershell\r\nName Value\r\n---- -----\r\nPSVersion 7.0.3\r\nPSEdition Core\r\nGitCommitId 7.0.3\r\nOS Microsoft Windows 10.0.18363\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/richard-browne","@type":"Person","name":"richard-browne"},"datePublished":"2021-09-21T01:39:08Z","url":"https://github.com/PowerShell/PowerShell/issues/16126"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cf0fd13c-8fcf-d707-29da-66b0408f3392 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD04:160FD0:2B2B4A8:3C391FE:6AFD5D0A |
| html-safe-nonce | 2efa3994b507c1338369742c0199d6f1b2c5f427107cdf36af3f224ddf9d3ca2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDA0OjE2MEZEMDoyQjJCNEE4OjNDMzkxRkU6NkFGRDVEMEEiLCJ2aXNpdG9yX2lkIjoiNDgzNjAxNjIyNTEzMTUxOTI0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a0f887f0fe6da9bb211ada5b5f0a39cb1c4adf59558f394c0c550ca21f3cb1d2 |
| hovercard-subject-tag | issue:1001653140 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/16126/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d31d79b9e72083690220c5e285159f76d411a16d8b63977456ee7b128ab86590/PowerShell/PowerShell/issues/16126 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d31d79b9e72083690220c5e285159f76d411a16d8b63977456ee7b128ab86590/PowerShell/PowerShell/issues/16126 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | richard-browne |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width