Skip to content

issue in _WD_ExecuteScript / __WD_EscapeString when comments // was used in JavaScript string #487

Closed
@mlipok

Description

@mlipok

Bug report

Describe the bug

$sData = StringRegExpReplace($sData, '[\v\t]', '')
from here:

au3WebDriver/wd_core.au3

Lines 1747 to 1749 in 42dda7d

Func __WD_EscapeString($sData, $iOption = 0)
If BitAND($iOption, $JSON_MLREFORMAT) Then
$sData = StringRegExpReplace($sData, '[\v\t]', '') ; Strip tabs and CR/LFs

strips [\v] chars and when // comment is used entire $sJavaScript becames commented out.

How to reproduce

_Example()
Func _Example()
	Local $sJavaScript = _
			"// comment" & @CRLF & _
			"return document.readyState;" & @CRLF & _
			""
	_WD_DebugSwitch($_WD_DEBUG_Full)
	_WD_ExecuteScript($sSession, $sJavaScript)
	_WD_DebugSwitch()
EndFunc   ;==>_Example

Expected behavior

get result from: return document.readyState;

Screenshots

none

Additional context

https://www.autoitscript.com/forum/topic/208640-webdriver-udf-help-support-iv/?do=findComment&comment=1521863

System under test

not related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions