From d02d73f41b4ec8c524f950028862f8fd9f195e83 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 19 Jan 2017 16:29:24 +0100 Subject: [PATCH] Prevent new lines in after/before decorator content. Fixes #18646 --- src/vs/editor/browser/services/codeEditorServiceImpl.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vs/editor/browser/services/codeEditorServiceImpl.ts b/src/vs/editor/browser/services/codeEditorServiceImpl.ts index 44fca7b0f5c..3731504b212 100644 --- a/src/vs/editor/browser/services/codeEditorServiceImpl.ts +++ b/src/vs/editor/browser/services/codeEditorServiceImpl.ts @@ -305,12 +305,14 @@ class DecorationRenderHelper { if (typeof opts !== 'undefined') { DecorationRenderHelper.collectBorderSettingsCSSText(opts, cssTextArr); if (typeof opts.contentIconPath === 'string') { - cssTextArr.push(strings.format(this._CSS_MAP.contentIconPath, URI.file(opts.contentIconPath).toString())); + cssTextArr.push(strings.format(this._CSS_MAP.contentIconPath, URI.file(opts.contentIconPath).toString().replace(/'/g, '%27'))); } else if (opts.contentIconPath instanceof URI) { cssTextArr.push(strings.format(this._CSS_MAP.contentIconPath, opts.contentIconPath.toString(true).replace(/'/g, '%27'))); } - if (typeof opts.contentText !== 'undefined') { - const escaped = opts.contentText.replace(/'/g, '\\\''); + if (typeof opts.contentText === 'string') { + const truncated = opts.contentText.match(/^.*$/m)[0]; // only take first line + const escaped = truncated.replace(/'\\/g, '\\$&'); + cssTextArr.push(strings.format(this._CSS_MAP.contentText, escaped)); } DecorationRenderHelper.collectCSSText(opts, ['textDecoration', 'color', 'backgroundColor', 'margin'], cssTextArr); -- GitLab