Closed
Bug 1419317
Opened 8 years ago
Closed 8 years ago
Text encoding issues with escape characters for script content (Execute Script / Execute Async Script)
Categories
(Remote Protocol :: Marionette, defect)
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: whimboo, Unassigned)
References
Details
It is currently not possible to run scripts which contain some of the valid escape characters. For example use the following call to execute_script:
> self.marionette.execute_script(""" return "\n"; """)
I would expect this script to return a new line string, but instead it fails with:
> JavascriptException: SyntaxError: unterminated string literal
Here more details in how the generated method to execute in evaluate.sandbox() actually looks like:
> (function() { return "
> "; }).apply(null, __webDriverArguments)
It means the escaped characters are getting directly interpreted and a new line is generated in the script body, which breaks its execution.
The underlying issue is basically a call like the following for `EvalInSandbox()`:
> Components.utils.evalInSandbox(`"a\nb"`, mySandbox);
Here a list of available escape characters:
https://en.wikipedia.org/wiki/Escape_character#JavaScript
allowed: \' \" \\ \n \r \t \b \f
not allowed: \v \0
Most of those don't work, especially those which cause a new line or escape a quote.
A simple replace doesn't seem to work, at least not for \n, because it would cause script content as done via multi-line strings in Python to break.
I cannot see any section in the spec which explains if those characters can be used or not.
Andreas and David, was that ever discussed? Or is that just our problem and needs to be fixed on our side, and it's not worth mentioning in the spec?
Flags: needinfo?(dburns)
Flags: needinfo?(ato)
Comment 1•8 years ago
|
||
this is because you are using a docstring and it is not escaping properly which is a known thing. you will need to put r''' docstring '''
Status: NEW → RESOLVED
Closed: 8 years ago
Flags: needinfo?(dburns)
Flags: needinfo?(ato)
Resolution: --- → INVALID
| Reporter | ||
Comment 2•8 years ago
|
||
Oh, I meant to reply here... Thanks for clarifying. I totally overlooked that part.
Updated•2 years ago
|
Product: Testing → Remote Protocol
You need to log in
before you can comment on or make changes to this bug.
Description
•