mirror of
https://github.com/pbatard/Fido.git
synced 2025-09-16 14:18:02 +02:00
Switch to basic parsing everywhere and perform our own DOM handling
* Addresses #19 * Also fix PowerShell 7.1.3 warnings
This commit is contained in:
28
Fido.ps1
28
Fido.ps1
@@ -64,7 +64,7 @@ $code = @"
|
|||||||
"@
|
"@
|
||||||
|
|
||||||
if ($host.version -ge "7.0") {
|
if ($host.version -ge "7.0") {
|
||||||
Add-Type -MemberDefinition $code -Namespace Gui -UsingNamespace System.Runtime, System.IO, System.Text, System.Drawing, System.Globalization -ReferencedAssemblies System.Drawing.Common -Name Utils -ErrorAction Stop
|
Add-Type -WarningAction Ignore -IgnoreWarnings -MemberDefinition $code -Namespace Gui -UsingNamespace System.Runtime, System.IO, System.Text, System.Drawing, System.Globalization -ReferencedAssemblies System.Drawing.Common -Name Utils -ErrorAction Stop
|
||||||
} else {
|
} else {
|
||||||
Add-Type -MemberDefinition $code -Namespace Gui -UsingNamespace System.IO, System.Text, System.Drawing, System.Globalization -ReferencedAssemblies System.Drawing -Name Utils -ErrorAction Stop
|
Add-Type -MemberDefinition $code -Namespace Gui -UsingNamespace System.IO, System.Text, System.Drawing, System.Globalization -ReferencedAssemblies System.Drawing -Name Utils -ErrorAction Stop
|
||||||
}
|
}
|
||||||
@@ -592,18 +592,11 @@ $Continue.add_click({
|
|||||||
$i = 0
|
$i = 0
|
||||||
$SelectedIndex = 0
|
$SelectedIndex = 0
|
||||||
try {
|
try {
|
||||||
$r = Invoke-WebRequest -UserAgent $UserAgent -SessionVariable "Session" $url
|
$r = Invoke-WebRequest -UseBasicParsing -UserAgent $UserAgent -SessionVariable "Session" $url
|
||||||
|
$pattern = '(?s)<select id="product-languages">(.*)?</select>'
|
||||||
|
$html = [regex]::Match($r, $pattern).Groups[1].Value
|
||||||
# Go through an XML conversion to keep all PowerShells happy...
|
# Go through an XML conversion to keep all PowerShells happy...
|
||||||
if (-not $($r.AllElements | ? {$_.id -eq "product-languages"})) {
|
|
||||||
if ($host.version -ge "7.0") {
|
|
||||||
throw "This PowerShell version can not parse HTML"
|
|
||||||
} else {
|
|
||||||
throw "Unexpected server response"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$html = $($r.AllElements | ? {$_.id -eq "product-languages"}).InnerHTML
|
|
||||||
$html = $html.Replace("selected value", "value")
|
$html = $html.Replace("selected value", "value")
|
||||||
$html = $html.Replace("&", "&")
|
|
||||||
$html = "<options>" + $html + "</options>"
|
$html = "<options>" + $html + "</options>"
|
||||||
$xml = [xml]$html
|
$xml = [xml]$html
|
||||||
foreach ($var in $xml.options.option) {
|
foreach ($var in $xml.options.option) {
|
||||||
@@ -647,18 +640,15 @@ $Continue.add_click({
|
|||||||
$array = @()
|
$array = @()
|
||||||
try {
|
try {
|
||||||
$Is64 = [Environment]::Is64BitOperatingSystem
|
$Is64 = [Environment]::Is64BitOperatingSystem
|
||||||
$r = Invoke-WebRequest -UserAgent $UserAgent -WebSession $Session $url
|
$r = Invoke-WebRequest -UseBasicParsing -UserAgent $UserAgent -WebSession $Session $url
|
||||||
if (-not $($r.AllElements | ? {$_.id -eq "expiration-time"})) {
|
$pattern = '(?s)(<input.*?/>)'
|
||||||
Throw-Error -Req $r -Alt Get-Translation($English[14])
|
ForEach-Object { [regex]::Matches($r, $pattern) } | ForEach-Object { $html += $_.Groups[1].value }
|
||||||
}
|
|
||||||
$html = $($r.AllElements | ? {$_.tagname -eq "input"}).outerHTML
|
|
||||||
# Need to fix the HTML and JSON data so that it is well-formed
|
# Need to fix the HTML and JSON data so that it is well-formed
|
||||||
$html = $html.Replace("class=product-download-hidden", "")
|
$html = $html.Replace("class=product-download-hidden", "")
|
||||||
$html = $html.Replace("type=hidden", "")
|
$html = $html.Replace("type=hidden", "")
|
||||||
$html = $html.Replace(">", "/>")
|
|
||||||
$html = $html.Replace(" ", " ")
|
$html = $html.Replace(" ", " ")
|
||||||
$html = $html.Replace("IsoX86", """x86""")
|
$html = $html.Replace("IsoX86", ""x86"")
|
||||||
$html = $html.Replace("IsoX64", """x64""")
|
$html = $html.Replace("IsoX64", ""x64"")
|
||||||
$html = "<inputs>" + $html + "</inputs>"
|
$html = "<inputs>" + $html + "</inputs>"
|
||||||
$xml = [xml]$html
|
$xml = [xml]$html
|
||||||
foreach ($var in $xml.inputs.input) {
|
foreach ($var in $xml.inputs.input) {
|
||||||
|
Reference in New Issue
Block a user