Filter out CDATA tag for RSS feeds (#691)

* add cdata regex

* remove cdata via regex

* add trailing comma

* fix no-useless-escape

* switch let to const
This commit is contained in:
Ben Sampson
2018-09-21 05:46:28 +01:00
committed by John Furrow
parent f3f01d6e96
commit 03d3943974
2 changed files with 9 additions and 0 deletions
+8
View File
@@ -6,6 +6,7 @@ const BaseService = require('./BaseService');
const client = require('../models/client');
const config = require('../../config');
const Feed = require('../models/Feed');
const regEx = require('../../shared/util/regEx');
class FeedService extends BaseService {
constructor() {
@@ -163,6 +164,13 @@ class FeedService extends BaseService {
// If there are no enclosures, then use the link tag instead
if (feedItem.link) {
// remove CDATA tags around links
const cdata = regEx.cdata.exec(feedItem.link);
if (cdata && cdata[1]) {
return [cdata[1]];
}
return [feedItem.link];
}
+1
View File
@@ -1,6 +1,7 @@
const regEx = {
url: /^(?:https?|ftp):\/\/.{1,}\.{1}.{1,}/,
domainName: /(?:https?|udp):\/\/(?:www\.)?([-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,18}\b)*(\/[/\d\w.-]*)*(?:[?])*(.+)*/i,
cdata: /<!\[CDATA\[(.*?)\]\]>/,
};
module.exports = regEx;