Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 43b0404

Browse files
authored
Release 1.11.2 (#675)
1 parent 5677a8a commit 43b0404

File tree

7 files changed

+33
-41
lines changed

7 files changed

+33
-41
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## 1.11.2 - 2022-01-10
6+
[FIX] IME not working properly #674
7+
58
## 1.11.1 - 2021-12-30
69
[FIX] Hide Livechat if Omnichannel is disabled #671
710

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rocket.chat/livechat",
3-
"version": "1.11.1",
3+
"version": "1.11.2",
44
"files": [
55
"/build"
66
],
@@ -91,7 +91,6 @@
9191
"css-vars-ponyfill": "^2.3.2",
9292
"date-fns": "^2.15.0",
9393
"desvg": "^1.0.2",
94-
"dompurify": "^2.2.6",
9594
"emoji-mart": "^3.0.0",
9695
"history": "^5.0.0",
9796
"i18nline": "^2.0.1",

src/components/Composer/index.js

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,8 @@
1-
import { sanitize } from 'dompurify';
2-
import mem from 'mem';
31
import { h, Component } from 'preact';
42

5-
import { createClassName } from '../helpers';
3+
import { createClassName, parse } from '../helpers';
64
import styles from './styles.scss';
75

8-
9-
const escapeMap = {
10-
'&': '&',
11-
'<': '&lt;',
12-
'>': '&gt;',
13-
'"': '&quot;',
14-
'\'': '&#x27;',
15-
'`': '&#x60;',
16-
};
17-
18-
const escapeRegex = new RegExp(`(?:${ Object.keys(escapeMap).join('|') })`, 'g');
19-
20-
const escapeHtml = mem(
21-
(string) => string.replace(escapeRegex, (match) => escapeMap[match]),
22-
);
23-
24-
const parse = (plainText) =>
25-
[{ plain: plainText }]
26-
.map(({ plain, html }) => (plain ? escapeHtml(plain) : html || ''))
27-
.join('');
28-
296
const findLastTextNode = (node) => {
307
if (node.nodeType === Node.TEXT_NODE) {
318
return node;
@@ -67,7 +44,7 @@ export class Composer extends Component {
6744
if (this.state.inputLock) {
6845
return;
6946
}
70-
onChange && onChange(sanitize(this.el.innerText));
47+
onChange && onChange(this.el.innerText);
7148
}
7249

7350
handleKeypress = (onSubmit) => (event) => {
@@ -98,6 +75,7 @@ export class Composer extends Component {
9875
items.filter((item) => item.kind === 'string' && /^text\/plain/.test(item.type))
9976
.map((item) => new Promise((resolve) => item.getAsString(resolve))),
10077
);
78+
10179
texts.forEach((text) => this.pasteText(parse(text)));
10280
}
10381

@@ -241,16 +219,12 @@ export class Composer extends Component {
241219
}
242220

243221
render = ({ pre, post, value, placeholder, onChange, onSubmit, onUpload, className, style }) => (
244-
245222
<div className={createClassName(styles, 'composer', { }, [className])} style={style}>
246223
{pre}
247224
<div
248225
ref={this.handleRef}
249226
{...(
250227
{
251-
dangerouslySetInnerHTML: {
252-
__html: parse(value),
253-
},
254228
contentEditable: true,
255229
'data-placeholder': placeholder,
256230
onInput: this.handleInput(onChange),
@@ -272,10 +246,10 @@ export class Composer extends Component {
272246

273247

274248
className={createClassName(styles, 'composer__input')}
275-
/>
249+
>{value}</div>
276250
{post}
277251
</div>
278-
)
252+
);
279253
}
280254

281255
export { ComposerAction } from './ComposerAction';

src/components/Messages/MessageText/markdown.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { sanitize } from 'dompurify';
21
import MarkdownIt from 'markdown-it';
32

43

@@ -81,4 +80,4 @@ md.use((md) => {
8180
});
8281
});
8382

84-
export const renderMarkdown = (...args) => sanitize(md.render(...args), { ADD_ATTR: ['target', 'rel'] });
83+
export const renderMarkdown = (...args) => md.render(...args);

src/components/helpers.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import parseISO from 'date-fns/parseISO';
2+
import mem from 'mem';
23
import { Component } from 'preact';
34

45
import { Livechat, useSsl } from '../api';
@@ -262,3 +263,23 @@ export const resolveDate = (dateInput) => {
262263
}
263264
}
264265
};
266+
267+
const escapeMap = {
268+
'&': '&amp;',
269+
'<': '&lt;',
270+
'>': '&gt;',
271+
'"': '&quot;',
272+
'\'': '&#x27;',
273+
'`': '&#x60;',
274+
};
275+
276+
const escapeRegex = new RegExp(`(?:${ Object.keys(escapeMap).join('|') })`, 'g');
277+
278+
const escapeHtml = mem(
279+
(string) => string.replace(escapeRegex, (match) => escapeMap[match]),
280+
);
281+
282+
export const parse = (plainText) =>
283+
[{ plain: plainText }]
284+
.map(({ plain, html }) => (plain ? escapeHtml(plain) : html || ''))
285+
.join('');

src/routes/Chat/container.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { route } from 'preact-router';
33

44
import { Livechat } from '../../api';
55
import { ModalManager } from '../../components/Modal';
6-
import { debounce, getAvatarUrl, canRenderMessage, throttle, upsert } from '../../components/helpers';
6+
import { debounce, getAvatarUrl, canRenderMessage, throttle, upsert, parse } from '../../components/helpers';
77
import I18n from '../../i18n';
88
import { normalizeQueueAlert } from '../../lib/api';
99
import constants from '../../lib/constants';
@@ -116,6 +116,7 @@ export class ChatContainer extends Component {
116116
if (msg.trim() === '') {
117117
return;
118118
}
119+
msg = parse(msg);
119120

120121
await this.grantUser();
121122
const { _id: rid } = await this.getRoom();

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5689,11 +5689,6 @@ domhandler@^2.3.0:
56895689
dependencies:
56905690
domelementtype "1"
56915691

5692-
dompurify@^2.2.6:
5693-
version "2.2.6"
5694-
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.2.6.tgz#54945dc5c0b45ce5ae228705777e8e59d7b2edc4"
5695-
integrity sha512-7b7ZArhhH0SP6W2R9cqK6RjaU82FZ2UPM7RO8qN1b1wyvC/NY1FNWcX1Pu00fFOAnzEORtwXe4bPaClg6pUybQ==
5696-
56975692
56985693
version "1.5.1"
56995694
resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf"

0 commit comments

Comments
 (0)