Skip to content

Commit

Permalink
deps: cherry-pick 2987946 from upstream V8
Browse files Browse the repository at this point in the history
Original commit message:

    Stop manual unescaping of script source data when preprocessing logs.

    It appears that the fields are already being unescaped elsewhere,
    perhaps by the JSON writer. So if we unescape when adding the source
    filename and contents, unescaping will happen again later and plain
    backslashes will be interpreted as escape codes.

    Bug: v8:6240
    Change-Id: Ic66b9017ae685d6dd12944ee8d254991e26fbd32
    Reviewed-on: https://chromium-review.googlesource.com/1186625
    Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
    Commit-Queue: Bret Sepulveda <bsep@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#55401}

Refs: v8/v8@2987946

PR-URL: #24555
Fixes: #20891
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
  • Loading branch information
refack authored and MylesBorins committed Nov 27, 2018
1 parent a66d877 commit e66c09e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.45',
'v8_embedder_string': '-node.46',

# Enable disassembler for `--print-code` v8 options
'v8_enable_disassembler': 1,
Expand Down
27 changes: 2 additions & 25 deletions deps/v8/tools/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1002,33 +1002,10 @@ JsonProfile.prototype.addSourcePositions = function(
};
};

function unescapeString(s) {
s = s.split("\\");
for (var i = 1; i < s.length; i++) {
if (s[i] === "") {
// Double backslash.
s[i] = "\\";
} else if (i > 0 && s[i].startsWith("x")) {
// Escaped Ascii character.
s[i] = String.fromCharCode(parseInt(s[i].substring(1, 3), 16)) +
s[i].substring(3);
} else if (i > 0 && s[i].startsWith("u")) {
// Escaped unicode character.
s[i] = String.fromCharCode(parseInt(s[i].substring(1, 5), 16)) +
s[i].substring(5);
} else {
if (i > 0 && s[i - 1] !== "\\") {
printErr("Malformed source string");
}
}
}
return s.join("");
}

JsonProfile.prototype.addScriptSource = function(script, url, source) {
this.scripts_[script] = {
name : unescapeString(url),
source : unescapeString(source)
name : url,
source : source
};
};

Expand Down

0 comments on commit e66c09e

Please sign in to comment.