fix escape twice's bug

This commit is contained in:
2021-01-17 20:47:38 +08:00
parent e74c7d70df
commit 80cfc9ddf7
4 changed files with 11 additions and 10 deletions

2
.gitignore vendored
View File

@@ -6,3 +6,5 @@ __pycache__/
Temp/
*.dll
*.so
*.so.*
*.xml

View File

@@ -41,9 +41,9 @@ from rssbotlib import loadRSSBotLib, AddVideoInfoResult
def getMediaInfo(m: dict, config: RSSConfig = RSSConfig()) -> str:
s = ''
if 'link' in m:
s = f"""{s}标题:<a href="{m['link']}">{escape(m['title'])}</a>"""
s = f"""{s}标题:<a href="{m['link']}">{m['title']}</a>"""
else:
s = f"{s}标题:{escape(m['title'])}"
s = f"{s}标题:{m['title']}"
if 'description' in m:
s = f"{s}\n描述:{escape(m['description'])}"
if 'ttl' in m and m['ttl'] is not None:
@@ -168,13 +168,13 @@ class main:
di['chat_id'] = chatId
text = textc()
if config.show_RSS_title:
text.addtotext(f"<b>{escape(meta['title'])}</b>")
text.addtotext(f"<b>{meta['title']}</b>")
if config.show_Content_title and 'title' in content and content['title'] is not None and content['title'] != '':
if 'link' in content and content['link'] is not None and content['link'] != '':
text.addtotext(
f"""<b><a href="{content['link']}">{escape(content['title'])}</a></b>""")
f"""<b><a href="{content['link']}">{content['title']}</a></b>""")
else:
text.addtotext(f"<b>{escape(content['title'])}</b>")
text.addtotext(f"<b>{content['title']}</b>")
elif 'link' in content and content['link'] is not None and content['link'] != '':
text.addtotext(
f"""<a href="{content['link']}">{escape(content['link'])}</a>""")

View File

@@ -18,7 +18,6 @@ from typing import List
from enum import Enum, unique
from math import ceil, floor
from textc import textc, timeToStr
from html import escape
@unique
@@ -45,7 +44,7 @@ class InlineKeyBoardForRSSList(Enum):
def getTextContentForRSSInList(rssEntry: RSSEntry) -> str:
text = textc()
text.addtotext(
f"""<a href="{rssEntry.url}">{escape(rssEntry.title)}</a>""")
f"""<a href="{rssEntry.url}">{rssEntry.title}</a>""")
temp = '更新间隔:未知' if rssEntry.interval is None else f'更新间隔:{rssEntry.interval}'
text.addtotext(temp)
temp = '上次更新时间:未知' if rssEntry.lastupdatetime is None or rssEntry.lastupdatetime < 0 else f'上次更新时间:{timeToStr(rssEntry.lastupdatetime)}'
@@ -63,7 +62,7 @@ def getTextContentForRSSInList(rssEntry: RSSEntry) -> str:
def getTextContentForRSSUnsubscribeInList(rssEntry: RSSEntry) -> str:
return f"""你是否要取消订阅<a href="{rssEntry.url}">{escape(rssEntry.title)}</a>?"""
return f"""你是否要取消订阅<a href="{rssEntry.url}">{rssEntry.title}</a>?"""
def getInlineKeyBoardForRSSList(chatId: int, RSSEntries: List[RSSEntry], page: int = 1, lastPage: bool = False, itemIndex: int = None) -> dict:

View File

@@ -245,7 +245,7 @@ class RSSParser:
else:
for k in i.childNodes:
s = s + k.toxml()
m[i.nodeName] = unescape(s)
m[i.nodeName] = s
elif typ == 'html':
s = ''
if i.nodeValue is not None:
@@ -256,7 +256,7 @@ class RSSParser:
p = HTMLSimpleParser()
if 'link' in m and m['link'] is not None:
p.baseUrl = m['link']
p.feed(unescape(s))
p.feed(s)
if p.data == '' and i.firstChild.nodeValue.find('<') == -1:
m[i.nodeName] = i.firstChild.nodeValue
else: