add decodeURI

This commit is contained in:
2021-01-08 18:14:01 +08:00
parent da5ad656b0
commit 4bbf589bac
2 changed files with 36 additions and 2 deletions

View File

@@ -27,7 +27,7 @@ from hashl import md5WithBase64
from enum import Enum
from rsstempdict import rssMetaInfo, rssMetaList
from random import randrange
from textc import textc, removeEmptyLine
from textc import textc, removeEmptyLine, decodeURI
from re import search, I
from rsschecker import RSSCheckerThread
from rsslist import getInlineKeyBoardForRSSList, InlineKeyBoardForRSSList, getInlineKeyBoardForRSSInList, getTextContentForRSSInList
@@ -492,7 +492,7 @@ class messageHandle(Thread):
self._uri = None
for i in self._botCommandPara:
if i.find('://') > -1:
self._uri = i
self._uri = decodeURI(i)
break
if self._data['chat']['type'] != "private" and checkUserPermissionsInChat(self._main, self._data['chat']['id'], self._fromUserId) != UserPermissionsInChatCheckResult.OK:
di['text'] = '你没有权限操作。'

View File

@@ -14,6 +14,7 @@
# 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/>.
from time import strftime, localtime, timezone
from urllib.parse import unquote
class textc:
@@ -53,3 +54,36 @@ def removeEmptyLine(s: str) -> str:
else:
z = z + '\n' + v
return z
def decodeURI(s: str) -> str:
s = s.replace('%25', '%2525')
s = s.replace('%3A', '%253A')
s = s.replace('%3a', '%253A')
s = s.replace('%2F', '%252F')
s = s.replace('%2f', '%252F')
s = s.replace('%3F', '%253F')
s = s.replace('%3f', '%253F')
s = s.replace('%23', '%2523')
s = s.replace('%5B', '%255B')
s = s.replace('%5b', '%255B')
s = s.replace('%5D', '%255D')
s = s.replace('%5d', '%255D')
s = s.replace('%40', '%2540')
s = s.replace('%21', '%2521')
s = s.replace('%24', '%2524')
s = s.replace('%26', '%2526')
s = s.replace('%27', '%2527')
s = s.replace('%28', '%2528')
s = s.replace('%29', '%2529')
s = s.replace('%2A', '%252A')
s = s.replace('%2a', '%252A')
s = s.replace('%2B', '%252B')
s = s.replace('%2b', '%252B')
s = s.replace('%2C', '%252C')
s = s.replace('%2c', '%252C')
s = s.replace('%3B', '%253B')
s = s.replace('%3b', '%253B')
s = s.replace('%3D', '%253D')
s = s.replace('%3d', '%253D')
s = s.replace('%20', '%2520')
return unquote(s)