Skip to content
Permalink
Browse files

Cleans up encodeXML function

  • Loading branch information...
davidmerfield committed Aug 30, 2019
1 parent 76d9e62 commit 5a71447082c3eb4e77394e633317d159bb34c053
Showing with 12 additions and 7 deletions.
  1. +12 −7 app/blog/render/retrieve/encodeXML.js
@@ -26,21 +26,26 @@ function removeXMLInvalidChars(string) {
// "(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]))",
// "g"
// );

string = string.replace(regex, "");
// string = string.replace(regex, "");

return string;
}

module.exports = function (req, callback) {
var base = req.protocol + "://" + req.get("host");
return callback(null, function() {
return function(text, render) {
var xml;

text = render(text);
text = absoluteURLs(base, text);
text = removeXMLInvalidChars(text, true);

return text;

try {
xml = absoluteURLs(req.protocol + "://" + req.get("host"), text);
xml = removeXMLInvalidChars(text);
} catch (e) {
// do nothing if we can't
}

return xml || text;
};
});
};

0 comments on commit 5a71447

Please sign in to comment.
You can’t perform that action at this time.