Skip to content

Commit

Permalink
Fix localization of error message 715-123130
Browse files Browse the repository at this point in the history
* As usual, Microsoft are completely unable to properly process UTF-8 content, even if
  the response from an Invoke-WebRequest query explicitly specifies "charset=utf-8".
* So, once again, we need to force PowerShell's hand to treat the content as UTF-8.
* Also improve the default error message if we can't get it from Microsoft.
  • Loading branch information
pbatard committed Nov 20, 2024
1 parent ce405fa commit c034a4e
Showing 1 changed file with 43 additions and 38 deletions.
81 changes: 43 additions & 38 deletions Fido.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Fido v1.62 - ISO Downloader, for Microsoft Windows and UEFI Shell
# Fido v1.63 - ISO Downloader, for Microsoft Windows and UEFI Shell
# Copyright © 2019-2024 Pete Batard <[email protected]>
# Command line support: Copyright © 2021 flx5
# ConvertTo-ImageSource: Copyright © 2016 Chris Carter
Expand Down Expand Up @@ -516,16 +516,21 @@ function Get-Code-715-123130-Message
Write-Host Querying $url
}
$r = Invoke-WebRequest -UseBasicParsing -TimeoutSec $DefaultTimeout -MaximumRedirection 0 $url
# Microsoft's handling of UTF-8 content is soooooooo *UTTERLY BROKEN*!!!
$r = [System.Text.Encoding]::UTF8.GetString($r.RawContentStream.ToArray())
# PowerShell 7 forces us to parse the HTML ourselves
$r = $r -replace "`n" -replace "`r"
$pattern = '.*<input id="msg-01" type="hidden" value="(.*?)"/>.*'
$msg = [regex]::Match($r, $pattern).Groups[1].Value
$msg = $msg -replace "&lt;", "<" -replace "<[^>]+>" -replace "\s+", " " -replace "\?\?\?", "-"
if ($msg -eq $null) {
$msg = $msg -replace "&lt;", "<" -replace "<[^>]+>" -replace "\s+", " "
if (($msg -eq $null) -or !($msg -match "715-123130")) {
throw
}
} catch {
$msg = "You are (temporarily) banned from using this Microsoft service. Please try againg later. Refer to message code 715-123130 and"
$msg = "Your IP address has been banned by Microsoft for issuing too many ISO download requests or for "
$msg += "belonging to a region of the world where sanctions currently apply. Please try again later.`r`n"
$msg += "If you believe this ban to be in error, you can try contacting Microsoft by referring to "
$msg += "message code 715-123130 and session ID "
}
return $msg
}
Expand Down Expand Up @@ -1068,8 +1073,8 @@ exit $ExitCode
# SIG # Begin signature block
# MIItPAYJKoZIhvcNAQcCoIItLTCCLSkCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCB0klYG7kMpXYlu
# 6Vmn7G7O3iGdiVPXhDhg2Qn662fa+aCCEkAwggVvMIIEV6ADAgECAhBI/JO0YFWU
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCD6jbVu0UdrYfJb
# 8cK/D+0aQvT69PGzJ/i6VUytxeUOc6CCEkAwggVvMIIEV6ADAgECAhBI/JO0YFWU
# jTanyYqJ1pQWMA0GCSqGSIb3DQEBDAUAMHsxCzAJBgNVBAYTAkdCMRswGQYDVQQI
# DBJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcMB1NhbGZvcmQxGjAYBgNVBAoM
# EUNvbW9kbyBDQSBMaW1pdGVkMSEwHwYDVQQDDBhBQUEgQ2VydGlmaWNhdGUgU2Vy
Expand Down Expand Up @@ -1171,23 +1176,23 @@ exit $ExitCode
# MS4wLAYDVQQDEyVTZWN0aWdvIFB1YmxpYyBDb2RlIFNpZ25pbmcgQ0EgRVYgUjM2
# AhA3xQo8HaADcccNx8YmkC/lMA0GCWCGSAFlAwQCAQUAoHwwEAYKKwYBBAGCNwIB
# DDECMAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcCAQQwHAYKKwYBBAGCNwIBCzEO
# MAwGCisGAQQBgjcCARUwLwYJKoZIhvcNAQkEMSIEIMda0hrcJMlznUby0JMTJZii
# YrlB+XbYbN64MDk3LZaPMA0GCSqGSIb3DQEBAQUABIICAKK5L6bwuDw5ehUQPObq
# jol9xp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LaJEa+DydmT
# qfrwUp93ygM3A4zesia7lWak0dY0RLkm64CTDmveFete2z7dCBwcwmEqNLOPifen
# xe8EZ1jeWu6ylRRMEF/nMt6N0YVyDpEOLoOFsk8byOMAFIkcwDA8XN+EzqlDpygq
# S06fEdD/aKU3ORZoMa4fccY1DdmZi7jQXiGep0zF1HGsLKxvZ3oP0pzhexlRu0NG
# /eJVzlgUWLfkmuToCuzwqQ==
# SIG # End signature block

0 comments on commit c034a4e

Please sign in to comment.