From e1c9981e9b868d4288a2248dfff825674ba8e6fe Mon Sep 17 00:00:00 2001 From: Arlo Breault Date: Wed, 7 Apr 2021 18:11:32 -0400 Subject: [PATCH] Use a protected key to distinguish comments internal to Parsoid Bug: T279451 Change-Id: Id10cc141269995f07b529fc4baed0464204bbf48 --- lib/utils/WTUtils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/utils/WTUtils.js b/lib/utils/WTUtils.js index 9544adc4d..6ef783f10 100644 --- a/lib/utils/WTUtils.js +++ b/lib/utils/WTUtils.js @@ -591,7 +591,7 @@ class WTUtils { */ static fosterCommentData(typeOf, attrs, encode) { let str = JSON.stringify({ - '@type': typeOf, + '-type': typeOf, attrs, }); if (encode) { str = WTUtils.encodeComment(str); } @@ -600,6 +600,7 @@ class WTUtils { static reinsertFosterableContent(env, node, decode) { if (DOMUtils.isComment(node) && /^\{[^]+\}$/.test(node.data)) { + decode = false; // Convert serialized meta tags back from comments. // We use this trick because comments won't be fostered, // providing more accurate information about where tags are expected @@ -607,7 +608,7 @@ class WTUtils { var data, type; try { data = JSON.parse(decode ? WTUtils.decodeComment(node.data) : node.data); - type = data["@type"]; + type = data["-type"]; } catch (e) { // not a valid json attribute, do nothing return null; -- 2.31.1