From a1a4e8c179e81de3f2d100352602cc724ccc43cc Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Sat, 10 Aug 2019 02:17:08 -0300 Subject: [PATCH 1/5] fix --- imports/client/@rocket.chat/apps-engine | 1 + 1 file changed, 1 insertion(+) create mode 120000 imports/client/@rocket.chat/apps-engine diff --git a/imports/client/@rocket.chat/apps-engine b/imports/client/@rocket.chat/apps-engine new file mode 120000 index 000000000000..9a368c3d1407 --- /dev/null +++ b/imports/client/@rocket.chat/apps-engine @@ -0,0 +1 @@ +../../../node_modules/@rocket.chat/apps-engine \ No newline at end of file From b416da1cccebf128e4b09e8322a1472fae3f46f3 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 13 Aug 2019 02:12:46 -0300 Subject: [PATCH 2/5] FIXED --- app/emoji/client/emojiParser.js | 29 ++++++++++++-------- app/markdown/lib/parser/original/markdown.js | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/emoji/client/emojiParser.js b/app/emoji/client/emojiParser.js index 00ef84402bee..56a0588e395c 100644 --- a/app/emoji/client/emojiParser.js +++ b/app/emoji/client/emojiParser.js @@ -32,25 +32,32 @@ Tracker.autorun(() => { const emojis = Array.from(checkEmojiOnly.querySelectorAll('.emoji:not(:empty), .emojione:not(:empty)')); + const filter = (node) => { + if (node.nodeType === Node.ELEMENT_NODE && ( + node.classList.contains('emojione') + || node.classList.contains('emoji') + )) { + return NodeFilter.FILTER_REJECT; + } + return NodeFilter.FILTER_ACCEPT; + }; + + // const filter = { + // acceptNode: file , + // }; const walker = document.createTreeWalker( checkEmojiOnly, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, - { - acceptNode: (node) => { - if (node.nodeType === Node.ELEMENT_NODE && ( - node.classList.contains('emojione') - || node.classList.contains('emoji') - )) { - return NodeFilter.FILTER_REJECT; - } - return NodeFilter.FILTER_ACCEPT; - }, - }, + null, + false ); let hasText = false; while (walker.nextNode()) { + if (filter(walker.currentNode) === NodeFilter.FILTER_REJECT) { + continue; + } if (walker.currentNode.nodeType === Node.TEXT_NODE && walker.currentNode.nodeValue.trim() !== '') { hasText = true; break; diff --git a/app/markdown/lib/parser/original/markdown.js b/app/markdown/lib/parser/original/markdown.js index 09517cd6fd4e..e0817c542f38 100644 --- a/app/markdown/lib/parser/original/markdown.js +++ b/app/markdown/lib/parser/original/markdown.js @@ -23,7 +23,7 @@ const parseNotEscaped = function(msg, message) { return token; }; - const schemes = settings.get('Markdown_SupportSchemesForLink').split(',').join('|'); + const schemes = (settings.get('Markdown_SupportSchemesForLink') || '').split(',').join('|'); if (settings.get('Markdown_Headers')) { // Support # Text for h1 From 27fc469b0bac34a1b77357243a225f8fc0c19485 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 13 Aug 2019 02:38:36 -0300 Subject: [PATCH 3/5] TOMA --- app/emoji/client/emojiParser.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/emoji/client/emojiParser.js b/app/emoji/client/emojiParser.js index 56a0588e395c..83a35c801235 100644 --- a/app/emoji/client/emojiParser.js +++ b/app/emoji/client/emojiParser.js @@ -42,22 +42,18 @@ Tracker.autorun(() => { return NodeFilter.FILTER_ACCEPT; }; - // const filter = { - // acceptNode: file , - // }; const walker = document.createTreeWalker( checkEmojiOnly, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, - null, - false + filter ); let hasText = false; while (walker.nextNode()) { - if (filter(walker.currentNode) === NodeFilter.FILTER_REJECT) { - continue; - } + // if (filter(walker.currentNode) === NodeFilter.FILTER_REJECT) { + // continue; + // } if (walker.currentNode.nodeType === Node.TEXT_NODE && walker.currentNode.nodeValue.trim() !== '') { hasText = true; break; From 4736d60874ea9f94803f6efe71b5c40b01d3392c Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 13 Aug 2019 02:38:36 -0300 Subject: [PATCH 4/5] TOMA --- app/emoji/client/emojiParser.js | 67 ++++++++++++++++----------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/app/emoji/client/emojiParser.js b/app/emoji/client/emojiParser.js index 56a0588e395c..ea64bb1ca48f 100644 --- a/app/emoji/client/emojiParser.js +++ b/app/emoji/client/emojiParser.js @@ -3,6 +3,7 @@ import { Meteor } from 'meteor/meteor'; import { Tracker } from 'meteor/tracker'; import { getUserPreference } from '../../utils'; +import { isIE } from '../../ui-utils/client/lib/isIE'; import { callbacks } from '../../callbacks'; import { emoji } from '../lib/rocketchat'; @@ -32,47 +33,43 @@ Tracker.autorun(() => { const emojis = Array.from(checkEmojiOnly.querySelectorAll('.emoji:not(:empty), .emojione:not(:empty)')); - const filter = (node) => { - if (node.nodeType === Node.ELEMENT_NODE && ( - node.classList.contains('emojione') - || node.classList.contains('emoji') - )) { - return NodeFilter.FILTER_REJECT; - } - return NodeFilter.FILTER_ACCEPT; - }; - - // const filter = { - // acceptNode: file , - // }; - const walker = document.createTreeWalker( - checkEmojiOnly, - NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, - null, - false - ); - let hasText = false; - while (walker.nextNode()) { - if (filter(walker.currentNode) === NodeFilter.FILTER_REJECT) { - continue; + if (!isIE()) { + const filter = (node) => { + if (node.nodeType === Node.ELEMENT_NODE && ( + node.classList.contains('emojione') + || node.classList.contains('emoji') + )) { + return NodeFilter.FILTER_REJECT; + } + return NodeFilter.FILTER_ACCEPT; + }; + + const walker = document.createTreeWalker( + checkEmojiOnly, + NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, + filter + ); + + + while (walker.nextNode()) { + if (walker.currentNode.nodeType === Node.TEXT_NODE && walker.currentNode.nodeValue.trim() !== '') { + hasText = true; + break; + } } - if (walker.currentNode.nodeType === Node.TEXT_NODE && walker.currentNode.nodeValue.trim() !== '') { - hasText = true; - break; + const emojiOnly = emojis.length && !hasText; + + if (emojiOnly) { + for (let i = 0, len = emojis.length; i < len; i++) { + const { classList } = emojis[i]; + classList.add('big'); + } + html = checkEmojiOnly.innerHTML; } } - const emojiOnly = emojis.length && !hasText; - - if (emojiOnly) { - for (let i = 0, len = emojis.length; i < len; i++) { - const { classList } = emojis[i]; - classList.add('big'); - } - html = checkEmojiOnly.innerHTML; - } // apostrophe (') back to ' html = html.replace(/\'/g, '''); From 03c342bf0db3a615cef86318db58c70d44c56c09 Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Tue, 13 Aug 2019 16:42:24 -0300 Subject: [PATCH 5/5] Rename helper as isIE11 --- app/emoji/client/emojiParser.js | 4 ++-- app/ui-utils/client/lib/isIE.js | 14 -------------- app/ui-utils/client/lib/isIE11.js | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 16 deletions(-) delete mode 100644 app/ui-utils/client/lib/isIE.js create mode 100644 app/ui-utils/client/lib/isIE11.js diff --git a/app/emoji/client/emojiParser.js b/app/emoji/client/emojiParser.js index ea64bb1ca48f..d7f7980df11a 100644 --- a/app/emoji/client/emojiParser.js +++ b/app/emoji/client/emojiParser.js @@ -3,7 +3,7 @@ import { Meteor } from 'meteor/meteor'; import { Tracker } from 'meteor/tracker'; import { getUserPreference } from '../../utils'; -import { isIE } from '../../ui-utils/client/lib/isIE'; +import { isIE11 } from '../../ui-utils/client/lib/isIE11'; import { callbacks } from '../../callbacks'; import { emoji } from '../lib/rocketchat'; @@ -35,7 +35,7 @@ Tracker.autorun(() => { let hasText = false; - if (!isIE()) { + if (!isIE11()) { const filter = (node) => { if (node.nodeType === Node.ELEMENT_NODE && ( node.classList.contains('emojione') diff --git a/app/ui-utils/client/lib/isIE.js b/app/ui-utils/client/lib/isIE.js deleted file mode 100644 index 91d184f94af1..000000000000 --- a/app/ui-utils/client/lib/isIE.js +++ /dev/null @@ -1,14 +0,0 @@ -export const isIE = function isIE() { - const { userAgent } = window.navigator; - const Idx = userAgent.indexOf('MSIE'); - - // If IE, return version number. - if (Idx > 0) { - return parseInt(userAgent.substring(Idx + 5, userAgent.indexOf('.', Idx))); - } - // If IE 11 then look for Updated user agent string. - if (navigator.userAgent.match(/Trident\/7\./)) { - return 11; - } - return 0; -}; diff --git a/app/ui-utils/client/lib/isIE11.js b/app/ui-utils/client/lib/isIE11.js new file mode 100644 index 000000000000..c494c5c63202 --- /dev/null +++ b/app/ui-utils/client/lib/isIE11.js @@ -0,0 +1,15 @@ +export const isIE11 = () => { + const { userAgent } = window.navigator; + const msieIdx = userAgent.indexOf('MSIE'); + + if (msieIdx > 0) { + return parseInt(userAgent.substring(msieIdx + 5, userAgent.indexOf('.', msieIdx))) === 11; + } + + // If MSIE detection fails, check the Trident engine version + if (navigator.userAgent.match(/Trident\/7\./)) { + return true; + } + + return false; +};