mirror of
https://github.com/zoriya/flood.git
synced 2026-06-01 02:29:01 +00:00
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:
@@ -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,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;
|
||||
|
||||
Reference in New Issue
Block a user