Fix link header parsing to handle unquoted rel types (#15973)

This commit is contained in:
Steven Liekens 2021-08-27 00:11:15 +02:00 committed by GitHub
parent d33b223674
commit 02b532fb1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1830,7 +1830,7 @@ namespace Microsoft.PowerShell.Commands
// we only support the URL in angle brackets and `rel`, other attributes are ignored
// user can still parse it themselves via the Headers property
const string pattern = "<(?<url>.*?)>;\\s*rel=(\"?)(?<rel>.*?)\\1[^\\w -.]?";
const string pattern = "<(?<url>.*?)>;\\s*rel=(?<quoted>\")?(?<rel>(?(quoted).*?|[^,;]*))(?(quoted)\")";
IEnumerable<string> links;
if (response.Headers.TryGetValues("Link", out links))
{