mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 03:41:58 +00:00
Refactor attachment_url_re to be a common value in upload.py.
This commit is contained in:
@@ -65,7 +65,8 @@ from zerver.lib.notifications import clear_followup_emails_queue
|
|||||||
from zerver.lib.narrow import check_supported_events_narrow_filter
|
from zerver.lib.narrow import check_supported_events_narrow_filter
|
||||||
from zerver.lib.request import JsonableError
|
from zerver.lib.request import JsonableError
|
||||||
from zerver.lib.session_user import get_session_user
|
from zerver.lib.session_user import get_session_user
|
||||||
from zerver.lib.upload import claim_attachment, delete_message_image
|
from zerver.lib.upload import attachment_url_re, claim_attachment, \
|
||||||
|
delete_message_image
|
||||||
from zerver.lib.str_utils import NonBinaryStr
|
from zerver.lib.str_utils import NonBinaryStr
|
||||||
|
|
||||||
import DNS
|
import DNS
|
||||||
@@ -3280,7 +3281,6 @@ def do_get_streams(user_profile, include_public=True, include_subscribed=True,
|
|||||||
|
|
||||||
def do_claim_attachments(message):
|
def do_claim_attachments(message):
|
||||||
# type: (Mapping[str, Any]) -> List[Tuple[text_type, bool]]
|
# type: (Mapping[str, Any]) -> List[Tuple[text_type, bool]]
|
||||||
attachment_url_re = re.compile(u'[/\-]user[\-_]uploads[/\.-].*?(?=[ )]|\Z)')
|
|
||||||
attachment_url_list = attachment_url_re.findall(message['message'].content)
|
attachment_url_list = attachment_url_re.findall(message['message'].content)
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
@@ -3309,7 +3309,6 @@ def do_delete_old_unclaimed_attachments(weeks_ago):
|
|||||||
|
|
||||||
def check_attachment_reference_change(prev_content, message):
|
def check_attachment_reference_change(prev_content, message):
|
||||||
new_content = message.content
|
new_content = message.content
|
||||||
attachment_url_re = re.compile(u'[/\-]user[\-_]uploads[/\.-].*?(?=[ )]|\Z)')
|
|
||||||
prev_attachments = set(attachment_url_re.findall(prev_content))
|
prev_attachments = set(attachment_url_re.findall(prev_content))
|
||||||
new_attachments = set(attachment_url_re.findall(new_content))
|
new_attachments = set(attachment_url_re.findall(new_content))
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ import logging
|
|||||||
# "file name" is the original filename provided by the user run
|
# "file name" is the original filename provided by the user run
|
||||||
# through a sanitization function.
|
# through a sanitization function.
|
||||||
|
|
||||||
|
attachment_url_re = re.compile(u'[/\-]user[\-_]uploads[/\.-].*?(?=[ )]|\Z)')
|
||||||
|
|
||||||
def sanitize_name(raw_value):
|
def sanitize_name(raw_value):
|
||||||
# type: (NonBinaryStr) -> text_type
|
# type: (NonBinaryStr) -> text_type
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user