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

Commit

Permalink
Release 1.11.2 (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoevanp committed Jan 12, 2022
1 parent 5677a8a commit 43b0404
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 41 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## 1.11.2 - 2022-01-10
[FIX] IME not working properly #674

## 1.11.1 - 2021-12-30
[FIX] Hide Livechat if Omnichannel is disabled #671

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rocket.chat/livechat",
"version": "1.11.1",
"version": "1.11.2",
"files": [
"/build"
],
Expand Down Expand Up @@ -91,7 +91,6 @@
"css-vars-ponyfill": "^2.3.2",
"date-fns": "^2.15.0",
"desvg": "^1.0.2",
"dompurify": "^2.2.6",
"emoji-mart": "^3.0.0",
"history": "^5.0.0",
"i18nline": "^2.0.1",
Expand Down
36 changes: 5 additions & 31 deletions src/components/Composer/index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
import { sanitize } from 'dompurify';
import mem from 'mem';
import { h, Component } from 'preact';

import { createClassName } from '../helpers';
import { createClassName, parse } from '../helpers';
import styles from './styles.scss';


const escapeMap = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
'\'': '&#x27;',
'`': '&#x60;',
};

const escapeRegex = new RegExp(`(?:${ Object.keys(escapeMap).join('|') })`, 'g');

const escapeHtml = mem(
(string) => string.replace(escapeRegex, (match) => escapeMap[match]),
);

const parse = (plainText) =>
[{ plain: plainText }]
.map(({ plain, html }) => (plain ? escapeHtml(plain) : html || ''))
.join('');

const findLastTextNode = (node) => {
if (node.nodeType === Node.TEXT_NODE) {
return node;
Expand Down Expand Up @@ -67,7 +44,7 @@ export class Composer extends Component {
if (this.state.inputLock) {
return;
}
onChange && onChange(sanitize(this.el.innerText));
onChange && onChange(this.el.innerText);
}

handleKeypress = (onSubmit) => (event) => {
Expand Down Expand Up @@ -98,6 +75,7 @@ export class Composer extends Component {
items.filter((item) => item.kind === 'string' && /^text\/plain/.test(item.type))
.map((item) => new Promise((resolve) => item.getAsString(resolve))),
);

texts.forEach((text) => this.pasteText(parse(text)));
}

Expand Down Expand Up @@ -241,16 +219,12 @@ export class Composer extends Component {
}

render = ({ pre, post, value, placeholder, onChange, onSubmit, onUpload, className, style }) => (

<div className={createClassName(styles, 'composer', { }, [className])} style={style}>
{pre}
<div
ref={this.handleRef}
{...(
{
dangerouslySetInnerHTML: {
__html: parse(value),
},
contentEditable: true,
'data-placeholder': placeholder,
onInput: this.handleInput(onChange),
Expand All @@ -272,10 +246,10 @@ export class Composer extends Component {


className={createClassName(styles, 'composer__input')}
/>
>{value}</div>
{post}
</div>
)
);
}

export { ComposerAction } from './ComposerAction';
Expand Down
3 changes: 1 addition & 2 deletions src/components/Messages/MessageText/markdown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { sanitize } from 'dompurify';
import MarkdownIt from 'markdown-it';


Expand Down Expand Up @@ -81,4 +80,4 @@ md.use((md) => {
});
});

export const renderMarkdown = (...args) => sanitize(md.render(...args), { ADD_ATTR: ['target', 'rel'] });
export const renderMarkdown = (...args) => md.render(...args);
21 changes: 21 additions & 0 deletions src/components/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import parseISO from 'date-fns/parseISO';
import mem from 'mem';
import { Component } from 'preact';

import { Livechat, useSsl } from '../api';
Expand Down Expand Up @@ -262,3 +263,23 @@ export const resolveDate = (dateInput) => {
}
}
};

const escapeMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
'\'': '&#x27;',
'`': '&#x60;',
};

const escapeRegex = new RegExp(`(?:${ Object.keys(escapeMap).join('|') })`, 'g');

const escapeHtml = mem(
(string) => string.replace(escapeRegex, (match) => escapeMap[match]),
);

export const parse = (plainText) =>
[{ plain: plainText }]
.map(({ plain, html }) => (plain ? escapeHtml(plain) : html || ''))
.join('');
3 changes: 2 additions & 1 deletion src/routes/Chat/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { route } from 'preact-router';

import { Livechat } from '../../api';
import { ModalManager } from '../../components/Modal';
import { debounce, getAvatarUrl, canRenderMessage, throttle, upsert } from '../../components/helpers';
import { debounce, getAvatarUrl, canRenderMessage, throttle, upsert, parse } from '../../components/helpers';
import I18n from '../../i18n';
import { normalizeQueueAlert } from '../../lib/api';
import constants from '../../lib/constants';
Expand Down Expand Up @@ -116,6 +116,7 @@ export class ChatContainer extends Component {
if (msg.trim() === '') {
return;
}
msg = parse(msg);

await this.grantUser();
const { _id: rid } = await this.getRoom();
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5689,11 +5689,6 @@ domhandler@^2.3.0:
dependencies:
domelementtype "1"

dompurify@^2.2.6:
version "2.2.6"
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.2.6.tgz#54945dc5c0b45ce5ae228705777e8e59d7b2edc4"
integrity sha512-7b7ZArhhH0SP6W2R9cqK6RjaU82FZ2UPM7RO8qN1b1wyvC/NY1FNWcX1Pu00fFOAnzEORtwXe4bPaClg6pUybQ==

domutils@1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf"
Expand Down

0 comments on commit 43b0404

Please sign in to comment.