Skip to content

_WD_ExecuteScript: don't reformat JS code #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Go to [legend](#legend---types-of-changes) for further information about the typ

## [Unreleased]

### Fixed

_WD_ExecuteScript: Eliminate reformatting of JS code

### Changed

- _WD_GetTable
Expand Down
12 changes: 2 additions & 10 deletions wd_core.au3
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ Global Const $_WD_JSON_Shadow = "[value][" & $_WD_SHADOW_ID & "]"
Global Const $_WD_JSON_Error = "[value][error]"
Global Const $_WD_JSON_Message = "[value][message]"

Global Const $JSON_MLREFORMAT = 1048576 ; Addition to constants from json.au3

Global Enum _
$_WD_DEBUG_None = 0, _ ; No logging
$_WD_DEBUG_Error, _ ; logging in case of Error
Expand Down Expand Up @@ -896,7 +894,7 @@ Func _WD_ExecuteScript($sSession, $sScript, $sArguments = Default, $bAsync = Def
If IsBool($vSubNode) Then $vSubNode = ($vSubNode) ? $_WD_JSON_Value : "" ; True = the JSON value node is returned , False = entire JSON response is returned

If IsString($vSubNode) Then
$sScript = __WD_EscapeString($sScript, $JSON_MLREFORMAT)
$sScript = __WD_EscapeString($sScript)

$sData = '{"script":"' & $sScript & '", "args":[' & $sArguments & ']}'
$sCmd = ($bAsync) ? 'async' : 'sync'
Expand Down Expand Up @@ -1738,18 +1736,12 @@ EndFunc ;==>__WD_CloseDriver
; $iOption - [optional] Any combination of $JSON_* constants. Default is 0.
; Author ........: Danp2
; Modified ......:
; Remarks .......: $JSON_MLREFORMAT will strip tabs and CR/LFs from a multiline string.
; See $JSON_* constants in json.au3 for other $iOption possibilities.
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func __WD_EscapeString($sData, $iOption = 0)
If BitAND($iOption, $JSON_MLREFORMAT) Then
$sData = StringRegExpReplace($sData, '[\v\t]', '') ; Strip tabs and CR/LFs
$iOption = BitXOR($iOption, $JSON_MLREFORMAT) ; Flip bit off
EndIf

$sData = Json_StringEncode($sData, $iOption) ; Escape JSON Strings

Return SetError($_WD_ERROR_Success, 0, $sData)
Expand Down