Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/component/sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import SortFilter from './sort_filter';
import { xtoast } from './message';
import { cssPrefix } from '../config';
import { formulas } from '../core/formula';
import {sanitizeHTML} from '../core/validator'

/**
* @desc throttle fn
Expand Down Expand Up @@ -499,6 +500,7 @@ function dataSetCellText(text, state = 'finished') {
const { data, table } = this;
// const [ri, ci] = selector.indexes;
if (data.settings.mode === 'read') return;
text = sanitizeHTML(text)
data.setSelectedCellText(text, state);
const { ri, ci } = data.selector;
if (state === 'finished') {
Expand Down
6 changes: 5 additions & 1 deletion src/core/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ function returnMessage(flag, key, ...arg) {
}
return [flag, message];
}

export function sanitizeHTML(str) {
return str.replace(/[^\w. ]/gi, function (c) {
return '&#' + c.charCodeAt(0) + ';';
});
};
export default class Validator {
// operator: b|nb|eq|neq|lt|lte|gt|gte
// type: date|number|list|phone|email
Expand Down