feat(core): Add 'Get-Encoding()' function to fix missing webClient encoding (#4956)

Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
This commit is contained in:
yi_Xu
2022-06-13 23:21:57 +08:00
committed by GitHub
parent d63b7d6f01
commit 6e25e440af
8 changed files with 37 additions and 14 deletions

View File

@@ -113,7 +113,7 @@ $Queue | ForEach-Object {
} else {
$wc.Headers.Add('User-Agent', (Get-UserAgent))
}
Register-ObjectEvent $wc downloadstringcompleted -ErrorAction Stop | Out-Null
Register-ObjectEvent $wc downloadDataCompleted -ErrorAction Stop | Out-Null
$githubRegex = '\/releases\/tag\/(?:v|V)?([\d.]+)'
@@ -190,7 +190,7 @@ $Queue | ForEach-Object {
}
$wc.Headers.Add('Referer', (strip_filename $url))
$wc.DownloadStringAsync($url, $state)
$wc.DownloadDataAsync($url, $state)
}
function next($er) {
@@ -218,7 +218,7 @@ while ($in_progress -gt 0) {
$ver = $Version
if (!$ver) {
$page = $ev.SourceEventArgs.Result
$page = (Get-Encoding($wc)).GetString($ev.SourceEventArgs.Result)
$err = $ev.SourceEventArgs.Error
if ($json.checkver.script) {
$page = Invoke-Command ([scriptblock]::Create($json.checkver.script -join "`r`n"))

View File

@@ -44,7 +44,8 @@ $Queue | ForEach-Object {
try {
$wc = New-Object Net.Webclient
$wc.Headers.Add('User-Agent', (Get-UserAgent))
$home_html = $wc.DownloadString($manifest.homepage)
$homepage = $wc.DownloadData($manifest.homepage)
$home_html = (Get-Encoding($wc)).GetString($homepage)
} catch {
Write-Host "`n$($_.Exception.Message)" -ForegroundColor Red
return