-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Add support in BasicHtmlWebResponseObject for open-ended input tags #16193
Add support in BasicHtmlWebResponseObject for open-ended input tags #16193
Conversation
test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
Outdated
Show resolved
Hide resolved
@@ -219,7 +219,7 @@ private static void EnsureHtmlParser() | |||
|
|||
if (s_inputFieldRegex == null) | |||
{ | |||
s_inputFieldRegex = new Regex(@"<input\s+[^>]*(/>|>.*?</input>)", | |||
s_inputFieldRegex = new Regex(@"<input\s+[^>]*(/>|>|>.*?</input>)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s_inputFieldRegex = new Regex(@"<input\s+[^>]*(/>|>|>.*?</input>)", | |
s_inputFieldRegex = new Regex(@"<input\s+[^>]*(/?>|>.*?</input>)", |
I think this is a bit of an easier to read / simpler regex expression that should have the same result.
bca62e6
to
337e349
Compare
test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
Outdated
Show resolved
Hide resolved
- Supports open-ended (no end slash) input tags, to match void element spec. - Adds unit tests confirming other forms of input tags are unaffected. Update unit tests and simplify regular expression Leverage testcases
337e349
to
9e51abe
Compare
@iSazonov is there a next step for merging? I'm not an authorized member. From what I can tell, it should be okay to happen 1 business day after approval. |
@farmerau We are waiting MSFT members to review. Since it is Regex they can find compliance issues. /cc @daxian-dbw @TravisEz13 friendly ping. |
@farmerau Thanks for your contribution! |
🎉 Handy links: |
PR Summary
Per #16126,
BasicHtmlWebResponseObject
didn't fully support valid html forinput
fields. Specifically, for anInvoke-WebRequest
that returns this valid html:would have a null
InputFields
value.To solve this, I've added an alternative construct to the regular expression (as recommended by the author of the issue) that requires neither a closing slash '/' nor a closing input tag ''.
Additionally, I've created Pester test cases to validate the outcome of the updated expression.
PR Context
(For reference #15973)
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).