@@ -1218,6 +1218,8 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
1218
1218
$sMethod = __WinHttpAttribVal($sAttributes , " method" )
1219
1219
; Requested form is found. Set $fSend flag to true
1220
1220
$fSend = True
1221
+ Local $sSpr1 = Chr (27 ), $sSpr2 = Chr (26 )
1222
+ __WinHttpNormalizeForm($sForm , $sSpr1 , $sSpr2 )
1221
1223
$aInput = StringRegExp ($sForm , " (?si)<\h*(?:input|textarea|label|fieldset|legend|select|optgroup|option|button)\h*(.*?)/*\h*>" , 3 )
1222
1224
If @error Then Return SetError (2 , 0 , " " ) ; invalid form
1223
1225
; HTML5 allows for "formaction", "formenctype", "formmethod" submit-control attributes to be set. If such control is "clicked" then form's attributes needs updating/correcting
@@ -1233,8 +1235,8 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
1233
1235
For $i = 0 To UBound ($aInput ) - 1 ; for all input elements
1234
1236
__WinHttpFormAttrib($aInputIds , $i , $aInput [$i ])
1235
1237
If $aInputIds [1 ][$i ] Then ; if there is 'name' field then add it
1236
- $aInputIds [1 ][$i ] = __WinHttpURLEncode($aInputIds [1 ][$i ], $sEnctype )
1237
- $aInputIds [2 ][$i ] = __WinHttpURLEncode($aInputIds [2 ][$i ], $sEnctype )
1238
+ $aInputIds [1 ][$i ] = __WinHttpURLEncode(StringReplace ( $aInputIds [1 ][$i ], $sSpr1 , " " ) , $sEnctype )
1239
+ $aInputIds [2 ][$i ] = __WinHttpURLEncode(StringReplace ( StringReplace ( $aInputIds [2 ][$i ], $sSpr2 , " > " ), $sSpr1 , " " ) , $sEnctype )
1238
1240
$sAddData &= $aInputIds [1 ][$i ] & " =" & $aInputIds [2 ][$i ] & " &"
1239
1241
If $aInputIds [3 ][$i ] = " submit" Then $sSubmit &= $aInputIds [1 ][$i ] & " =" & $aInputIds [2 ][$i ] & $sGrSep ; add to overall "submit" string
1240
1242
If $aInputIds [3 ][$i ] = " radio" Then $sRadio &= $aInputIds [1 ][$i ] & " =" & $aInputIds [2 ][$i ] & $sGrSep ; add to overall "radio" string
@@ -1373,6 +1375,8 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
1373
1375
For $i = 0 To UBound ($aInput ) - 1 ; for all input elements
1374
1376
__WinHttpFormAttrib($aInputIds , $i , $aInput [$i ])
1375
1377
If $aInputIds [1 ][$i ] Then ; if there is 'name' field
1378
+ $aInputIds [1 ][$i ] = StringReplace ($aInputIds [1 ][$i ], $sSpr1 , " " )
1379
+ $aInputIds [2 ][$i ] = StringReplace (StringReplace ($aInputIds [2 ][$i ], $sSpr2 , " >" ), $sSpr1 , " " )
1376
1380
If $aInputIds [3 ][$i ] = " file" Then
1377
1381
$sAddData &= " --" & $sBoundary & @CRLF & _
1378
1382
$sCDisp & $aInputIds [1 ][$i ] & ' "; filename=""' & @CRLF & @CRLF & _
@@ -2214,6 +2218,34 @@ Func __WinHttpHTML5FormAttribs(ByRef $aDtas, ByRef $aFlds, ByRef $iNumParams, By
2214
2218
EndIf
2215
2219
EndFunc
2216
2220
2221
+ Func __WinHttpNormalizeForm(ByRef $sForm , $sSpr1 , $sSpr2 )
2222
+ Local $aData = StringToASCIIArray ($sForm , Default , Default , 2 )
2223
+ Local $sOut , $bQuot = False , $bSQuot = False
2224
+ For $i = 0 To UBound ($aData ) - 1
2225
+ Switch $aData [$i ]
2226
+ Case 34
2227
+ $bQuot = Not $bQuot
2228
+ Case 39
2229
+ $bSQuot = Not $bSQuot
2230
+ Case 32 ; space
2231
+ If $bQuot Or $bSQuot Then
2232
+ $sOut &= $sSpr1
2233
+ Else
2234
+ $sOut &= Chr ($aData [$i ])
2235
+ EndIf
2236
+ Case 62 ; >
2237
+ If $bQuot Or $bSQuot Then
2238
+ $sOut &= $sSpr2
2239
+ Else
2240
+ $sOut &= Chr ($aData [$i ])
2241
+ EndIf
2242
+ Case Else
2243
+ $sOut &= Chr ($aData [$i ])
2244
+ EndSwitch
2245
+ Next
2246
+ $sForm = $sOut
2247
+ EndFunc
2248
+
2217
2249
Func __WinHttpFinalizeCtrls($sSubmit , $sRadio , $sCheckBox , $sButton , ByRef $sAddData , $sGrSep , $sBound = " " )
2218
2250
If $sSubmit Then ; If no submit is specified
2219
2251
Local $aSubmit = StringSplit ($sSubmit , $sGrSep , 3 )
0 commit comments