mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 10:25:08 +01:00
Move escapeHTML to dom utils
This commit is contained in:
parent
4d4cb7f505
commit
17762ed7b2
@ -8,8 +8,8 @@ import audiojs from '../../third_party/imports/audiojs';
|
|||||||
import shmui from '../../third_party/imports/shmui';
|
import shmui from '../../third_party/imports/shmui';
|
||||||
import videojs from '../../third_party/imports/videojs';
|
import videojs from '../../third_party/imports/videojs';
|
||||||
|
|
||||||
|
import { escapeHTML } from '../../utils/dom';
|
||||||
import { extractFileExtensionFromUrl } from '../../utils/file';
|
import { extractFileExtensionFromUrl } from '../../utils/file';
|
||||||
import { escapeHTML } from '../../utils/general';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,19 @@ import React from 'react';
|
|||||||
|
|
||||||
import { getLinkRegex, isEmail } from './regex';
|
import { getLinkRegex, isEmail } from './regex';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape HTML in a string so it can be injected safely using React's `dangerouslySetInnerHTML`
|
||||||
|
*
|
||||||
|
* @param {string} s String to be sanitized
|
||||||
|
* @return {string} Sanitized string
|
||||||
|
*
|
||||||
|
* Taken from: http://stackoverflow.com/a/17546215/597097
|
||||||
|
*/
|
||||||
|
export function escapeHTML(s) {
|
||||||
|
return document.createElement('div').appendChild(document.createTextNode(s)).parentNode.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the title in the browser window.
|
* Set the title in the browser window.
|
||||||
*/
|
*/
|
||||||
|
@ -14,15 +14,3 @@ export {
|
|||||||
sanitizeList,
|
sanitizeList,
|
||||||
selectFromObject
|
selectFromObject
|
||||||
} from 'js-utility-belt/es6';
|
} from 'js-utility-belt/es6';
|
||||||
|
|
||||||
/**
|
|
||||||
* Escape HTML in a string so it can be injected safely using
|
|
||||||
* React's `dangerouslySetInnerHTML`
|
|
||||||
*
|
|
||||||
* @param s the string to be sanitized
|
|
||||||
*
|
|
||||||
* Taken from: http://stackoverflow.com/a/17546215/597097
|
|
||||||
*/
|
|
||||||
export function escapeHTML(s) {
|
|
||||||
return document.createElement('div').appendChild(document.createTextNode(s)).parentNode.innerHTML;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user