Skip to content

Commit ef80c6f

Browse files
committed
_WD_ExecuteScript: don't reformat JS code (#489)
1 parent 3beb429 commit ef80c6f

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
Go to [legend](#legend---types-of-changes) for further information about the types of changes.
1111

12+
## [Unreleased]
13+
14+
### Fixed
15+
16+
_WD_ExecuteScript: Eliminate reformatting of JS code
17+
1218
## [1.1.0] 2023-07-17
1319

1420
### Changed

wd_core.au3

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ Global Const $_WD_JSON_Shadow = "[value][" & $_WD_SHADOW_ID & "]"
8888
Global Const $_WD_JSON_Error = "[value][error]"
8989
Global Const $_WD_JSON_Message = "[value][message]"
9090

91-
Global Const $JSON_MLREFORMAT = 1048576 ; Addition to constants from json.au3
92-
9391
Global Enum _
9492
$_WD_DEBUG_None = 0, _ ; No logging
9593
$_WD_DEBUG_Error, _ ; logging in case of Error
@@ -896,7 +894,7 @@ Func _WD_ExecuteScript($sSession, $sScript, $sArguments = Default, $bAsync = Def
896894
If IsBool($vSubNode) Then $vSubNode = ($vSubNode) ? $_WD_JSON_Value : "" ; True = the JSON value node is returned , False = entire JSON response is returned
897895

898896
If IsString($vSubNode) Then
899-
$sScript = __WD_EscapeString($sScript, $JSON_MLREFORMAT)
897+
$sScript = __WD_EscapeString($sScript)
900898

901899
$sData = '{"script":"' & $sScript & '", "args":[' & $sArguments & ']}'
902900
$sCmd = ($bAsync) ? 'async' : 'sync'
@@ -1736,23 +1734,21 @@ EndFunc ;==>__WD_CloseDriver
17361734
; Syntax ........: __WD_EscapeString($sData[, $iOption = 0])
17371735
; Parameters ....: $sData - the string to be escaped
17381736
; $iOption - [optional] Any combination of $JSON_* constants. Default is 0.
1737+
; Return values..: Success - Escaped string
1738+
; Failure - Response from JSON UDF and sets @error to $_WD_ERROR_GeneralError
17391739
; Author ........: Danp2
17401740
; Modified ......:
1741-
; Remarks .......: $JSON_MLREFORMAT will strip tabs and CR/LFs from a multiline string.
1742-
; See $JSON_* constants in json.au3 for other $iOption possibilities.
1741+
; Remarks .......: See $JSON_* constants in json.au3 for the possible $iOption combinations.
17431742
; Related .......:
17441743
; Link ..........:
17451744
; Example .......: No
17461745
; ===============================================================================================================================
17471746
Func __WD_EscapeString($sData, $iOption = 0)
1748-
If BitAND($iOption, $JSON_MLREFORMAT) Then
1749-
$sData = StringRegExpReplace($sData, '[\v\t]', '') ; Strip tabs and CR/LFs
1750-
$iOption = BitXOR($iOption, $JSON_MLREFORMAT) ; Flip bit off
1751-
EndIf
1752-
1747+
Local $iErr = $_WD_ERROR_Success
17531748
$sData = Json_StringEncode($sData, $iOption) ; Escape JSON Strings
17541749

1755-
Return SetError($_WD_ERROR_Success, 0, $sData)
1750+
If @error Then $iErr = $_WD_ERROR_GeneralError
1751+
Return SetError($iErr, 0, $sData)
17561752
EndFunc ;==>__WD_EscapeString
17571753

17581754
; #INTERNAL_USE_ONLY# ===========================================================================================================

0 commit comments

Comments
 (0)