@@ -1139,7 +1139,7 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
1139
1139
EndIf
1140
1140
EndIf
1141
1141
; Get page source
1142
- Local $hOpen , $sHTML , $fVarForm , $iScheme = $INTERNET_SCHEME_HTTP
1142
+ Local $hOpen , $aHTML , $ sHTML, $sURL , $fVarForm , $iScheme = $INTERNET_SCHEME_HTTP
1143
1143
If IsString ($hInternet ) Then ; $hInternet is page source
1144
1144
$sHTML = $hInternet
1145
1145
If _WinHttpQueryOption($sActionPage , $WINHTTP_OPTION_HANDLE_TYPE ) <> $WINHTTP_HANDLE_TYPE_SESSION Then Return SetError (6 , 0 , " " )
@@ -1149,19 +1149,23 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
1149
1149
$iScheme = _WinHttpQueryOption($hInternet , $WINHTTP_OPTION_CONTEXT_VALUE ); read internet scheme from the connection handle
1150
1150
Local $sAccpt = " Accept: text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5"
1151
1151
If $iScheme = $INTERNET_SCHEME_HTTPS Then
1152
- $sHTML = _WinHttpSimpleSSLRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , Default , Default , $sCredName , $sCredPass , $iIgnoreCertErr )
1152
+ $aHTML = _WinHttpSimpleSSLRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , 1 , Default , $sCredName , $sCredPass , $iIgnoreCertErr )
1153
1153
ElseIf $iScheme = $INTERNET_SCHEME_HTTP Then
1154
- $sHTML = _WinHttpSimpleRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , Default , Default , $sCredName , $sCredPass )
1154
+ $aHTML = _WinHttpSimpleRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , 1 , Default , $sCredName , $sCredPass )
1155
1155
Else
1156
1156
; Try both http and https scheme and deduct the right one besed on response
1157
- $sHTML = _WinHttpSimpleRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , Default , Default , $sCredName , $sCredPass )
1157
+ $aHTML = _WinHttpSimpleRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , 1 , Default , $sCredName , $sCredPass )
1158
1158
If @error Or @extended > = $HTTP_STATUS_BAD_REQUEST Then
1159
- $sHTML = _WinHttpSimpleSSLRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , Default , Default , $sCredName , $sCredPass , $iIgnoreCertErr )
1159
+ $aHTML = _WinHttpSimpleSSLRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , 1 , Default , $sCredName , $sCredPass , $iIgnoreCertErr )
1160
1160
$iScheme = $INTERNET_SCHEME_HTTPS
1161
1161
Else
1162
1162
$iScheme = $INTERNET_SCHEME_HTTP
1163
1163
EndIf
1164
1164
EndIf
1165
+ If Not @error Then ; Error is checked after If...Then...Else block. Be careful before changing anything!
1166
+ $sHTML = $aHTML [1 ]
1167
+ $sURL = $aHTML [2 ]
1168
+ EndIf
1165
1169
EndIf
1166
1170
$sHTML = StringRegExpReplace ($sHTML , " (?s)<!--.*?-->" , " " ) ; removing comments
1167
1171
$sHTML = StringRegExpReplace ($sHTML , " (?s)<!\[CDATA\[.*?\]\]>" , " " ) ; removing CDATA
@@ -1217,7 +1221,7 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
1217
1221
; HTML5 allows for "formaction", "formenctype", "formmethod" submit-control attributes to be set. If such control is "clicked" then form's attributes needs updating/correcting
1218
1222
__WinHttpHTML5FormAttribs($aDtas , $aFlds , $iNumParams , $aInput , $sAction , $sEnctype , $sMethod )
1219
1223
; Workout correct URL, scheme, etc...
1220
- __WinHttpNormalizeActionURL($sActionPage , $sAction , $iScheme , $sNewURL , $sEnctype , $sMethod )
1224
+ __WinHttpNormalizeActionURL($sActionPage , $sAction , $iScheme , $sNewURL , $sEnctype , $sMethod , $sURL )
1221
1225
If $fVarForm And Not $sNewURL Then Return SetError (5 , 0 , " " ) ; "action" must have URL specified
1222
1226
Local $aSplit , $sBoundary , $sPassedId , $sPassedData , $iNumRepl , $fMultiPart = False , $sSubmit , $sRadio , $sCheckBox , $sButton
1223
1227
Local $sGrSep = Chr (29 )
@@ -2035,7 +2039,7 @@ Func __WinHttpHTMLDecode($vData)
2035
2039
Return StringReplace (StringReplace (StringReplace (StringReplace ($vData , " &" , " &" ), " <" , " <" ), " >" , " >" ), " "" , ' "' )
2036
2040
EndFunc
2037
2041
2038
- Func __WinHttpNormalizeActionURL($sActionPage , ByRef $sAction , ByRef $iScheme , ByRef $sNewURL , ByRef $sEnctype , ByRef $sMethod )
2042
+ Func __WinHttpNormalizeActionURL($sActionPage , ByRef $sAction , ByRef $iScheme , ByRef $sNewURL , ByRef $sEnctype , ByRef $sMethod , $sURL = " " )
2039
2043
Local $aCrackURL = _WinHttpCrackUrl($sAction )
2040
2044
If @error Then
2041
2045
If $sAction Then
0 commit comments