diff --git a/daemon.py b/daemon.py index 7d6a956d4..a8dfa0cac 100644 --- a/daemon.py +++ b/daemon.py @@ -12225,7 +12225,8 @@ class PubServer(BaseHTTPRequestHandler): calling_domain: str, path: str, base_dir: str, http_prefix: str, domain: str, port: int, - debug: str, curr_session) -> bool: + debug: str, curr_session, + cookie: str) -> bool: """get conversation thread from the date link on a post """ if not authorized: @@ -12284,9 +12285,15 @@ class PubServer(BaseHTTPRequestHandler): if conv_str: msg = conv_str.encode('utf-8') msglen = len(msg) - self._login_headers('text/html', - msglen, calling_domain) + self._login_headers('text/html', msglen, calling_domain) self._write(msg) + self.server.getreq_busy = False + return True + # redirect to the original site if there are no results + if '://' + self.server.domain_full + '/' in post_id: + self._redirect_headers(post_id, cookie, calling_domain) + else: + self._redirect_headers(post_id, None, calling_domain) self.server.getreq_busy = False return True @@ -16964,7 +16971,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.domain, self.server.port, self.server.debug, - self.server.session): + self.server.session, + cookie): fitness_performance(getreq_start_time, self.server.fitness, '_GET', '_show_conversation_thread', self.server.debug) diff --git a/tests.py b/tests.py index 40b2ef2c8..625df2196 100644 --- a/tests.py +++ b/tests.py @@ -54,6 +54,7 @@ from follow import clear_followers from follow import send_follow_request_via_server from follow import send_unfollow_request_via_server from siteactive import site_is_active +from utils import html_tag_has_closing from utils import remove_inverted_text from utils import remove_square_capitals from utils import standardize_text @@ -7777,6 +7778,22 @@ def _test_replace_remote_tags() -> None: assert result == expected +def _test_html_closing_tag() -> None: + print('html_closing_tag') + content = '

@ooh@wibbly.wobbly.worldLike, ' + \ + 'OMG!

Something with
some-widget ' + \ + 'and something else ' + \ + 'totally' + \ + ' on the razzle.

As for it
' + \ + 'WHATEVER' + \ + ' archaeopteryx.

' + assert html_tag_has_closing('code', content) + + content = '

Some code

' + assert not html_tag_has_closing('code', content) + + def run_all_tests(): base_dir = os.getcwd() print('Running tests...') @@ -7794,6 +7811,7 @@ def run_all_tests(): _test_checkbox_names() _test_thread_functions() _test_functions() + _test_html_closing_tag() _test_replace_remote_tags() _test_replace_variable() _test_missing_theme_colors(base_dir) diff --git a/utils.py b/utils.py index 638ca9766..d9d368d01 100644 --- a/utils.py +++ b/utils.py @@ -1130,7 +1130,7 @@ def _is_dangerous_string_simple(content: str, allow_local_network_access: bool, return False -def _html_tag_has_closing(tag_name: str, content: str) -> bool: +def html_tag_has_closing(tag_name: str, content: str) -> bool: """Does the given tag have opening and closing labels? """ content_lower = content.lower() @@ -1148,9 +1148,11 @@ def _html_tag_has_closing(tag_name: str, content: str) -> bool: return False if tag_name == 'code': # check that lines are not too long + section = section.split(end_tag)[0] code_lines = section.split('\n') for line in code_lines: if len(line) >= 60: + print(' line too long') return False ctr += 1 return True @@ -1166,7 +1168,7 @@ def dangerous_markup(content: str, allow_local_network_access: bool) -> bool: if _is_dangerous_string_simple(content, allow_local_network_access, separators, invalid_strings): return True - if not _html_tag_has_closing('code', content): + if not html_tag_has_closing('code', content): return True invalid_strings = [ 'script', 'noscript', 'pre',