Merge remote-tracking branch 'origin/master'

This commit is contained in:
Frisk 2021-11-17 15:35:15 +01:00
commit 4e36d3fb82
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC
2 changed files with 3 additions and 7 deletions

View file

@ -622,7 +622,7 @@ async def embed_formatter(action, change, parsed_comment, categories, recent_cha
embed["color"] = 8750469
link = "{wiki}index.php?title={article}&curid={pageid}&diff={diff}&oldid={oldrev}".format(
wiki=WIKI_SCRIPT_PATH, pageid=change["pageid"], diff=change["revid"], oldrev=change["old_revid"],
article=change["title"].replace(" ", "_").replace("%", "%25").replace("\\", "%5C").replace("&", "%26"))
article=change["title"].replace(" ", "_").replace("%", "%25").replace("\\", "%5C").replace("&", "%26").replace("?", "%3F"))
embed["title"] = "{redirect}{article} ({new}{minor}{bot}{space}{editsize})".format(redirect="" if "redirect" in change else "", article=change["title"], editsize="+" + str(
editsize) if editsize > 0 else editsize, new=_("(N!) ") if action == "new" else "",
minor=_("m") if action == "edit" and "minor" in change else "", bot=_('b') if "bot" in change else "", space=" " if "bot" in change or (action == "edit" and "minor" in change) or action == "new" else "")
@ -688,7 +688,7 @@ async def embed_formatter(action, change, parsed_comment, categories, recent_cha
logger.warning("Request for additional image information have failed. The preview will not be shown.")
if action in ("upload/overwrite", "upload/revert"):
if additional_info_retrieved:
article_encoded = change["title"].replace(" ", "_").replace("%", "%25").replace("\\", "%5C").replace("&", "%26").replace(')', '\\)')
article_encoded = change["title"].replace(" ", "_").replace("%", "%25").replace("\\", "%5C").replace("&", "%26").replace("?", "%3F").replace(')', '\\)')
try:
revision = img_info[num+1]
except IndexError:

View file

@ -83,11 +83,7 @@ def escape_formatting(data: str) -> str:
def create_article_path(article: str, WIKI_ARTICLE_PATH: str) -> str:
"""Takes the string and creates an URL with it as the article name"""
article = article.replace(" ", "_").replace("%", "%25").replace("\\", "%5C")
if "?" in WIKI_ARTICLE_PATH:
article = article.replace("&", "%26")
else:
article = article.replace("?", "%3F")
article = article.replace(" ", "_").replace("%", "%25").replace("\\", "%5C").replace("?", "%3F").replace("&", "%26")
return WIKI_ARTICLE_PATH.replace("$1", article)