From 6866a320262e9fd9c5a232df11dc7105aa5296eb Mon Sep 17 00:00:00 2001 From: Takuma YOSHIOKA Date: Wed, 5 Jul 2017 01:10:58 +0900 Subject: [PATCH 1/2] Fix queet box behaviour (around newlines) in firefox --- js/qvitter.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/qvitter.js b/js/qvitter.js index c454eea..561fcd0 100644 --- a/js/qvitter.js +++ b/js/qvitter.js @@ -2848,8 +2848,11 @@ $('body').on('click', '.queet-toolbar button',function () { var queetBoxID = queetBox.attr('id'); // jquery's .text() function is not consistent in converting
:s to \n:s, - // so we do this detour to make sure line breaks are preserved - queetBox.html(queetBox.html().replace(/
/g, '{{{lb}}}')); + // so we do this detour to make sure line breaks are preserved. + // In firefox (and maybe some other browsers), queetBox.html() may have
s + // and may or may not have
in them. + // To deal with this, remove any
s right before
and then add ones. + queetBox.html(queetBox.html().replace(/(
)*<\/div>/g, '
').replace(/
/g, '{{{lb}}}')); var queetText = $.trim(queetBox.text().replace(/^\s+|\s+$/g, '').replace(/\n/g, '')); queetText = queetText.replace(/{{{lb}}}/g, "\n"); From 444cce2c3b2a9fd4d4a14f90a79541097b1aebae Mon Sep 17 00:00:00 2001 From: Takuma YOSHIOKA Date: Wed, 5 Jul 2017 13:59:40 +0900 Subject: [PATCH 2/2] Escape `{` and `}` to preserve `{{{lb}}}` in queet text --- js/qvitter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/qvitter.js b/js/qvitter.js index 561fcd0..e1b7d9c 100644 --- a/js/qvitter.js +++ b/js/qvitter.js @@ -2852,9 +2852,9 @@ $('body').on('click', '.queet-toolbar button',function () { // In firefox (and maybe some other browsers), queetBox.html() may have
s // and may or may not have
in them. // To deal with this, remove any
s right before
and then add ones. - queetBox.html(queetBox.html().replace(/(
)*<\/div>/g, '
').replace(/
/g, '{{{lb}}}')); + queetBox.html(queetBox.html().replace(/(
)*<\/div>/g, '
').replace(/({|})/g, '!$1').replace(/
/g, '{{{lb}}}')); var queetText = $.trim(queetBox.text().replace(/^\s+|\s+$/g, '').replace(/\n/g, '')); - queetText = queetText.replace(/{{{lb}}}/g, "\n"); + queetText = queetText.replace(/{{{lb}}}/g, "\n").replace(/!({|})/g, '$1'); var queetTempText = replaceHtmlSpecialChars(queetText.replace(/\n/g,'
')); // no xss queetTempText = queetTempText.replace(/<br>/g,'
'); // but preserve line breaks