Skip to content

Commit a0c93f6

Browse files
committed
Fixed: URL encoding added for parameters when needed for _WinHttpSimpleFormFill.
1 parent d58b9ff commit a0c93f6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

WinHttp.au3

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,13 +1224,14 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
12241224
__WinHttpNormalizeActionURL($sActionPage, $sAction, $iScheme, $sNewURL, $sEnctype, $sMethod, $sURL)
12251225
If $fVarForm And Not $sNewURL Then Return SetError(5, 0, "") ; "action" must have URL specified
12261226
Local $aSplit, $sBoundary, $sPassedId, $sPassedData, $iNumRepl, $fMultiPart = False, $sSubmit, $sRadio, $sCheckBox, $sButton
1227-
Local $sGrSep = Chr(29)
1227+
Local $sGrSep = Chr(29), $iErr
12281228
Local $aInputIds[4][UBound($aInput)]
12291229
Switch $sEnctype
12301230
Case "", "application/x-www-form-urlencoded", "text/plain"
12311231
For $i = 0 To UBound($aInput) - 1 ; for all input elements
12321232
__WinHttpFormAttrib($aInputIds, $i, $aInput[$i])
12331233
If $aInputIds[1][$i] Then ; if there is 'name' field then add it
1234+
$aInputIds[1][$i] = __WinHttpURLEncode($aInputIds[1][$i], $sEnctype)
12341235
$aInputIds[2][$i] = __WinHttpURLEncode($aInputIds[2][$i], $sEnctype)
12351236
$sAddData &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & "&"
12361237
If $aInputIds[3][$i] = "submit" Then $sSubmit &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "submit" string
@@ -1250,8 +1251,11 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
12501251
$sPassedId = $aFlds[$k]
12511252
$aFlds[$k] = 0
12521253
$aSplit = StringSplit($sPassedId, ":", 2)
1253-
If @error Or $aSplit[0] <> "name" Then ; like .getElementById
1254-
If Not @error And $aSplit[0] = "id" Then $sPassedId = $aSplit[1]
1254+
$iErr = @error
1255+
$aSplit[0] = __WinHttpURLEncode($aSplit[0], $sEnctype)
1256+
If Not $iErr Then $aSplit[1] = __WinHttpURLEncode($aSplit[1], $sEnctype)
1257+
If $iErr Or $aSplit[0] <> "name" Then ; like .getElementById
1258+
If Not $iErr And $aSplit[0] = "id" Then $sPassedId = $aSplit[1]
12551259
For $j = 0 To UBound($aInputIds, 2) - 1
12561260
If $aInputIds[0][$j] = $sPassedId Then
12571261
If $aInputIds[3][$j] = "submit" Then

0 commit comments

Comments
 (0)