Sfoglia il codice sorgente

fixed sanitize handlebars helper to accept not only strings

bubble
Anna Bodnia 8 anni fa
parent
commit
eaf59c1e8c
3 ha cambiato i file con 52 aggiunte e 23 eliminazioni
  1. +25
    -10
      dist/swagger-ui.js
  2. +9
    -9
      dist/swagger-ui.min.js
  3. +18
    -4
      src/main/javascript/helpers/handlebars.js

+ 25
- 10
dist/swagger-ui.js
File diff soppresso perché troppo grande
Vedi File


+ 9
- 9
dist/swagger-ui.min.js
File diff soppresso perché troppo grande
Vedi File


+ 18
- 4
src/main/javascript/helpers/handlebars.js Vedi File

@@ -1,12 +1,26 @@
'use strict';
/*jslint eqeq: true*/

var sanitize = function(html) {
html = html || '';
// Strip the script tags from the html, and return it as a Handlebars.SafeString
var _sanitize = function(html) {
// Strip the script tags from the html and inline evenhandlers
html = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
html = html.replace(/(on\w+="[^"]*")*(on\w+='[^']*')*(on\w+=\w*\(\w*\))*/gi, '');
return new Handlebars.SafeString(html);

return html;
};

var sanitize =function (html) {
var _html;
if( _.isUndefined(html) || _.isNull(html) || _.isNumber(html)) {
return new Handlebars.SafeString(html);
}

if (_.isObject(html)){
_html = JSON.stringify(html);
return new Handlebars.SafeString(JSON.parse(_sanitize(_html)));
}

return new Handlebars.SafeString(_sanitize(html));
};

Handlebars.registerHelper('sanitize', sanitize);


Caricamento…
Annulla
Salva