Repository navigation
Limit searching of charset attribute in meta tag for HTML to first 1024 characters in webcmdlets - #17813
Conversation
…t 1024 characters in webcmdlets
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
🎉 Handy links: |
…t 1024 characters in webcmdlets (PowerShell#17813)
PR Summary
In the case of HTML content, the cmdlet searches for
<meta charset=...>in the body to find the right encoding to use. It uses a regex to do this, however, it applies it to the entire body (which can be quite large). The<meta>tag exists in the<head>tag which is expected at the top of the document under<html>. So the change here is to limit the search to just the first 1k characters. It is possible (since HTML is pretty lenient) to have a bunch of HTML comment tags that pushes the<meta>tag much lower, but seems unlikely. The encoding defaults to UTF-8 which is used by most websites anyways.Tested manually against the repro in the issue which returns immediately after the payload is downloaded.
PR Context
Fix #17762
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).