-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Description
Describe the bug
It seems that single quote strings don't work too well with special characters that need to be escaped, like ", or '.
To Reproduce
Open the MathJS website, the webbrowser console, and type:
math.evaluate("'te\"st'")math.evaluate("'te\'st'")
Result
- Uncaught SyntaxError: Unexpected non-whitespace character after JSON at position 4 (line 1 column 5) at JSON.parse ()
- SymbolNode.js:109 Uncaught Error: Undefined symbol st at Function.value
Exptected result
'te"st'"te'st"
Other comments
It is worth noting that the first issue (1.) can be workaround by typing math.evaluate("'te\\\"st'"). However, the second issue (2.) cannot be fixed by using any number of backslashes.
This problem may be related to the following line:
mathjs/src/expression/parse.js
Line 1483 in 4a62e7c
| return JSON.parse('"' + str + '"') // unescape escaped characters |
where single-quoted string content is actually enclosed in double quotes. Also, I understand that there are some possible conflicts with the transpose operator, but I am not sure how this could or should affect characters escaping.