try use defusedxml first to avoid some attack.
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
requests>=2.25.1
|
requests>=2.25.1
|
||||||
|
defusedxml>=0.6.0; python_version < '3.9'
|
||||||
|
|||||||
11
rssparser.py
11
rssparser.py
@@ -14,6 +14,13 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
|
defusedxmlSupported = True
|
||||||
|
try:
|
||||||
|
from defusedxml.minidom import parse, parseString
|
||||||
|
except:
|
||||||
|
parse = minidom.parse
|
||||||
|
parseString = minidom.parseString
|
||||||
|
defusedxmlSupported = False
|
||||||
from html.parser import HTMLParser
|
from html.parser import HTMLParser
|
||||||
from html import escape, unescape
|
from html import escape, unescape
|
||||||
import sys
|
import sys
|
||||||
@@ -351,9 +358,9 @@ class RSSParser:
|
|||||||
re = requests.get(fn)
|
re = requests.get(fn)
|
||||||
re.encoding = 'utf8'
|
re.encoding = 'utf8'
|
||||||
if re.status_code == 200:
|
if re.status_code == 200:
|
||||||
self.xmldoc = minidom.parseString(re.text)
|
self.xmldoc = parseString(re.text)
|
||||||
else:
|
else:
|
||||||
self.xmldoc = minidom.parse(fn)
|
self.xmldoc = parse(fn)
|
||||||
self.normalize()
|
self.normalize()
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
|
|||||||
Reference in New Issue
Block a user