Escape sequences are not properly displayed in the console
Reported by
pyg...@gmail.com,
Feb 21 2018
|
||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Iridium/58.0 Safari/537.36 Chrome/58.0.3029.81 Steps to reproduce the problem: 1. console.log( ["a\\n", "a\"b", "\v", "\n", "\\"] ) // notice the array 2. get back an array of fancy strings unlike those that were passed, some of which are not valid JS strings: ["a\n", "a"b", "", "↵", "\"] While the vertical tab isn't immediately mangled, if follow these steps, you end up with a string containing the 65533 code point: 1) console.log(["\v"]) at the console. 2) copy the result, an apparently empty string, into the clipboard and 3) paste it to the console, press return. 4) copy the previous prompt (not the result) 5) paste it It has turned into "\uFFFD". What is the expected behavior? Unmangled output that is also valid JS and can round trip to source code. What went wrong? See above. Did this work before? N/A Chrome version: 63.0.3239.132 Channel: stable OS Version: OS X 10.12.6 Flash Version:
,
Feb 28 2018
Able to reproduce this issue on Mac 10.13.3, Win-10 and Ubuntu 14.04 using chrome reported version #63.0.3239.132, latest stable #64.0.3282.186 and latest canary #66.0.3356.0. This is a non-regression issue as it is observed from M60 old builds. Hence, marking it as untriaged to get more inputs from dev team. Thanks...!!
,
Mar 3 2018
,
May 22 2018
Thank you for the report. I see 3 cases where we need to decide whether to display "valid-JS" output vs "presentable" output.
Case 1) Strings with the '\' or '"' character, e.g. "a\\n", "a\"b", "\\"
I'm fine with updating our display to be closer to valid-JS, and show "\\" here. Firefox and Safari DevTools also do this.
Case 2) Strings with '\n'
Currently Chrome and Safari DevTools may show the '↵' ("\u21B5") character, which makes it easier to detect line breaks in a long string. Since Chrome and other vendors have used this for a long time, I don't think we have enough feedback to change it for now.
Case 3) Strings with control codes, e.g. '\v'
You are correct that DevTools currently replaces these with the "\uFFFD" replacement character. It was intentionally [1] done this way a couple years ago to avoid cases where users pasted text in the Console and did not realize there was a hidden character. Chrome renders '\v' as a rectangle character on my Linux machine, but it appears empty on my Mac. I think the "presentable" output is important here to catch errors, and we should seek more feedback before changing this.
[1] https://bugs.chromium.org/p/chromium/issues/detail?id=586799
,
May 22 2018
After some offline discussion, I think we need to come up with a UX solution or wait for more feedback before changing current behavior. DevTools is currently consistently showing "presentable" output instead of "JS-valid" output by design. There are some workarounds for the case you described. Given an array, you can use the `copy(arr)` command line function to copy the actual parameters, which will provide you the full, escaped array entries. |
||||
►
Sign in to add a comment |
||||
Comment 1 by sindhu.chelamcherla@chromium.org
, Feb 21 2018