dashboard: add escape-html npm package

This commit is contained in:
Kurkó Mihály 2018-07-13 11:31:10 +03:00
parent bcb290bff0
commit 029982ef5c
5 changed files with 421 additions and 392 deletions

File diff suppressed because it is too large Load diff

View file

@ -69,11 +69,3 @@ export const styles = {
color: 'rgba(255, 255, 255, 0.54)',
},
};
// htmlEscape replaces the HTML specific special characters in a string.
export const htmlEscape = (str: string) => str
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');

View file

@ -19,8 +19,8 @@
import React, {Component} from 'react';
import List, {ListItem} from 'material-ui/List';
import escapeHtml from 'escape-html';
import type {Record, Content, LogsMessage, Logs as LogsType} from '../types/content';
import {htmlEscape} from '../common';
// requestBand says how wide is the top/bottom zone, eg. 0.1 means 10% of the container height.
const requestBand = 0.05;
@ -84,8 +84,8 @@ const createChunk = (records: Array<Record>) => {
content += `<span style="color:${color}">${lvl}</span>[${month}-${date}|${hours}:${minutes}:${seconds}] ${msg}`;
for (let i = 0; i < ctx.length; i += 2) {
const key = htmlEscape(ctx[i]);
const val = htmlEscape(ctx[i + 1]);
const key = escapeHtml(ctx[i]);
const val = escapeHtml(ctx[i + 1]);
let padding = fieldPadding.get(key);
if (typeof padding !== 'number' || padding < val.length) {
padding = val.length;

View file

@ -13,6 +13,7 @@
"babel-runtime": "^6.26.0",
"classnames": "^2.2.5",
"css-loader": "^0.28.9",
"escape-html": "^1.0.3",
"eslint": "^4.16.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-loader": "^2.0.0",
@ -41,7 +42,7 @@
"scripts": {
"build": "NODE_ENV=production webpack",
"stats": "webpack --profile --json > stats.json",
"dev": "webpack-dev-server --port 8081",
"flow": "flow-typed install"
"dev": "webpack-dev-server --port 8081",
"flow": "flow-typed install"
}
}

View file

@ -2248,7 +2248,7 @@ es6-weak-map@^2.0.1:
es6-iterator "^2.0.1"
es6-symbol "^3.1.1"
escape-html@~1.0.3:
escape-html@^1.0.3, escape-html@~1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"