bug fixed

This commit is contained in:
richard-loafle 2020-01-29 11:45:14 +09:00
parent 415de783c0
commit c294cc66b5
3 changed files with 25 additions and 10 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "ucap-webmessenger", "name": "ucap-webmessenger",
"version": "0.0.5", "version": "0.0.9",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -36,6 +36,7 @@ import {
of, of,
BehaviorSubject BehaviorSubject
} from 'rxjs'; } from 'rxjs';
import { import {
Info, Info,
EventType, EventType,
@ -733,7 +734,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
roomSeq: this.roomInfoSubject.value.roomSeq, roomSeq: this.roomInfoSubject.value.roomSeq,
eventType: EventType.MassText, eventType: EventType.MassText,
// sentMessage: message.replace(/\n/gi, '\r\n') // sentMessage: message.replace(/\n/gi, '\r\n')
sentMessage: message sentMessage: StringUtil.escapeHtml(message)
} }
}) })
); );

View File

@ -236,4 +236,18 @@ export class StringUtil {
} }
return eventMessage; return eventMessage;
} }
static escapeHtml(dirty: string): string {
return (dirty + '').replace(
/[&<>"']/g,
m =>
({
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;'
}[m])
);
}
} }