Skip to content

Commit

Permalink
Merge pull request #1927 from microsoft/dpaul-HstsFix
Browse files Browse the repository at this point in the history
Address bug with HSTS detection with no ; in value
  • Loading branch information
dpaulson45 authored Jan 5, 2024
2 parents a5c1cb4 + 3aeb429 commit b1e882f
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ function Get-IISWebSite {
# add 8 to find the start index after 'max-age='
$maxAgeIndex = $maxAgeIndex + 8

# subtract maxAgeIndex to get the length that we need to find the substring
$maxAgeValueIndex = $maxAgeValueIndex - $maxAgeIndex
$customHeaderHstsObj.'max-age' = $customHeaderHsts.Substring($maxAgeIndex, $maxAgeValueIndex)
if ($maxAgeValueIndex -ne -1) {
# subtract maxAgeIndex to get the length that we need to find the substring
$maxAgeValueIndex = $maxAgeValueIndex - $maxAgeIndex
$customHeaderHstsObj.'max-age' = $customHeaderHsts.Substring($maxAgeIndex, $maxAgeValueIndex)
} else {
$customHeaderHstsObj.'max-age' = $customHeaderHsts.Substring($maxAgeIndex)
}
} else {
Write-Verbose "max-age directive not found"
}
Expand Down

0 comments on commit b1e882f

Please sign in to comment.