@@ -1191,8 +1191,7 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
1191
1191
; Variables
1192
1192
Local $sForm , $sAttributes , $aInput
1193
1193
Local $iNumParams = Ceiling (($iNumArgs - 2 ) / 2 ) - 1
1194
- Local $sAddData
1195
- Local $aCrackURL , $sNewURL
1194
+ Local $sAddData , $sNewURL
1196
1195
; Loop thru all forms on the page and find one that was specified
1197
1196
For $iFormOrdinal = 0 To UBound ($aForm ) - 1
1198
1197
If $fGetFormByIndex And $iFormOrdinal <> $iFormIndex Then ContinueLoop
@@ -1210,33 +1209,15 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
1210
1209
$sAccept = __WinHttpAttribVal($sAttributes , " accept" )
1211
1210
$sEnctype = __WinHttpAttribVal($sAttributes , " enctype" )
1212
1211
$sMethod = __WinHttpAttribVal($sAttributes , " method" )
1213
- If Not $sMethod Then $sMethod = " GET"
1214
- If $sMethod = " GET" Then $sEnctype = " "
1215
- $aCrackURL = _WinHttpCrackUrl($sAction )
1216
- If @error Then
1217
- If $sAction Then
1218
- If StringLeft ($sAction , 1 ) <> " /" Then
1219
- Local $sCurrent
1220
- Local $aURL = StringRegExp ($sActionPage , ' (.*)/' , 3 )
1221
- If Not @error Then $sCurrent = $aURL [0 ]
1222
- If $sCurrent Then $sAction = $sCurrent & " /" & $sAction
1223
- EndIf
1224
- If StringLeft ($sAction , 1 ) = " ?" Then $sAction = $sActionPage & $sAction
1225
- EndIf
1226
- If Not $sAction Then $sAction = $sActionPage
1227
- $sAction = StringRegExpReplace ($sAction , " \A(/*\.\./)*" , " " ) ; /../
1228
- Else
1229
- $iScheme = $aCrackURL [1 ]
1230
- $sNewURL = $aCrackURL [0 ] & " ://" & $aCrackURL [2 ] & " :" & $aCrackURL [3 ]
1231
- $sAction = $aCrackURL [6 ] & $aCrackURL [7 ]
1232
- EndIf
1233
- If $fVarForm And Not $sNewURL Then Return SetError (5 , 0 , " " ) ; "action" must have URL specified
1234
1212
; Requested form is found. Set $fSend flag to true
1235
1213
$fSend = True
1236
- Local $aSplit , $sBoundary , $sPassedId , $sPassedData , $iNumRepl , $fMultiPart = False , $sSubmit , $sRadio , $sCheckBox , $sButton
1237
- Local $sGrSep = Chr (29 )
1238
1214
$aInput = StringRegExp ($sForm , " (?si)<\h*(?:input|textarea|label|fieldset|legend|select|optgroup|option|button)\h*(.*?)/*\h*>" , 3 )
1239
1215
If @error Then Return SetError (2 , 0 , " " ) ; invalid form
1216
+ ; Workout correct URL, scheme, etc...
1217
+ __WinHttpNormalizeActionURL($sActionPage , $sAction , $iScheme , $sNewURL , $sEnctype , $sMethod )
1218
+ If $fVarForm And Not $sNewURL Then Return SetError (5 , 0 , " " ) ; "action" must have URL specified
1219
+ Local $aSplit , $sBoundary , $sPassedId , $sPassedData , $iNumRepl , $fMultiPart = False , $sSubmit , $sRadio , $sCheckBox , $sButton
1220
+ Local $sGrSep = Chr (29 )
1240
1221
Local $aInputIds [4 ][UBound ($aInput )]
1241
1222
Switch $sEnctype
1242
1223
Case " " , " application/x-www-form-urlencoded" , " text/plain"
@@ -2026,6 +2007,29 @@ Func __WinHttpHTMLDecode($vData)
2026
2007
Return StringReplace (StringReplace (StringReplace (StringReplace ($vData , " &" , " &" ), " <" , " <" ), " >" , " >" ), " "" , ' "' )
2027
2008
EndFunc
2028
2009
2010
+ Func __WinHttpNormalizeActionURL($sActionPage , ByRef $sAction , ByRef $iScheme , ByRef $sNewURL , ByRef $sEnctype , ByRef $sMethod )
2011
+ Local $aCrackURL = _WinHttpCrackUrl($sAction )
2012
+ If @error Then
2013
+ If $sAction Then
2014
+ If StringLeft ($sAction , 1 ) <> " /" Then
2015
+ Local $sCurrent
2016
+ Local $aURL = StringRegExp ($sActionPage , ' (.*)/' , 3 )
2017
+ If Not @error Then $sCurrent = $aURL [0 ]
2018
+ If $sCurrent Then $sAction = $sCurrent & " /" & $sAction
2019
+ EndIf
2020
+ If StringLeft ($sAction , 1 ) = " ?" Then $sAction = $sActionPage & $sAction
2021
+ EndIf
2022
+ If Not $sAction Then $sAction = $sActionPage
2023
+ $sAction = StringRegExpReplace ($sAction , " \A(/*\.\./)*" , " " ) ; /../
2024
+ Else
2025
+ $iScheme = $aCrackURL [1 ]
2026
+ $sNewURL = $aCrackURL [0 ] & " ://" & $aCrackURL [2 ] & " :" & $aCrackURL [3 ]
2027
+ $sAction = $aCrackURL [6 ] & $aCrackURL [7 ]
2028
+ EndIf
2029
+ If Not $sMethod Then $sMethod = " GET"
2030
+ If $sMethod = " GET" Then $sEnctype = " "
2031
+ EndFunc
2032
+
2029
2033
Func __WinHttpFinalizeCtrls($sSubmit , $sRadio , $sCheckBox , $sButton , ByRef $sAddData , $sGrSep , $sBound = " " )
2030
2034
If $sSubmit Then ; If no submit is specified
2031
2035
Local $aSubmit = StringSplit ($sSubmit , $sGrSep , 3 )
0 commit comments