How to use the escapeHTML function from underscore.string

Find comprehensive JavaScript underscore.string.escapeHTML code examples handpicked from public code repositorys.

12
13
14
15
16
17
18
19
20
21
  res.locals.csrfToken =
    typeof req.csrfToken === "function" ? req.csrfToken() : undefined
  res.locals.sd.CSRF_TOKEN = res.locals.csrfToken
}
if (res.locals.sd != null) {
  res.locals.error = escapeHTML(req.query.error)
  res.locals.sd.ERROR = res.locals.error
}
if (res.locals.sd != null) {
  res.locals.ap = pick(
fork icon145
star icon533
watch icon65

337
338
339
340
341
342
343
344
345
346
const host = config.client.host;
const reversedEscapeChars = { '<': 'lt', '>': 'gt', '"': 'quot', '&': 'amp', "'": '#39' };
const trailingChars = '\\s).,;>';

function escape(txt) {
    //Паттерн из _s.escapeHTML(result); исключая амперсант
    return txt.replace(/[<>"']/g, m => `&${reversedEscapeChars[m]};`);
}

return function (txt) {
fork icon14
star icon70
watch icon0

+ 13 other calls in file

11
12
13
14
15
16
17
18
19
20
if (res.locals.sd != null) {
  res.locals.csrfToken = typeof req.csrfToken === 'function' ? req.csrfToken() : undefined;
  res.locals.sd.CSRF_TOKEN = res.locals.csrfToken;
}
if (res.locals.sd != null) {
  res.locals.error = escapeHTML(req.query.error);
  res.locals.sd.ERROR = res.locals.error;
}
if (res.locals.sd != null) {
  res.locals.ap = pick(
fork icon18
star icon10
watch icon55

33
34
35
36
37
38
39
40
41
42
43
44
exports.clean = function(value, options, callback){
    callback(null, str.clean(String(value)));
};


exports.escapeHTML = function(value, options, callback){
    callback(null, str.escapeHTML(String(value)));
};


exports.unescapeHTML = function(value, options, callback){
    callback(null, str.unescapeHTML(String(value)));
fork icon2
star icon2
watch icon0

+ 2 other calls in file

197
198
199
200
201
202
203
204
205
206
207
208
function handleSocket(user, message) {
    var data = JSON.parse(message);


    data.id = user.id;
    data.user = user.un;
    data.type = s.escapeHTML(data.type);
    data.message = s.escapeHTML(data.message);
    data.mid = (Math.random() + 1).toString(36).substr(2, 5);


    switch(data.type) {
fork icon1
star icon1
watch icon0

28
29
30
31
32
33
34
35
36
37
},
rawurlencode: function(value) {
	return encodeURIComponent(value);
},
htmlentities: function(value, args) {
	return _string.escapeHTML(value);
},
escapejs: function(value) {
	return _string.quote(value);
},
fork icon0
star icon1
watch icon0

+ 2 other calls in file

193
194
195
196
197
198
199
200
201
202
203
204
function handleSocket(user, message) {
    var data = JSON.parse(message)


    data.id = user.id
    data.user = user.un
    data.type = s.escapeHTML(data.type)
    data.message = s.escapeHTML(data.message)
    data.mid = (Math.random() + 1).toString(36).substr(2, 5)


    switch (data.type) {
fork icon0
star icon0
watch icon0

+ 7 other calls in file