diff --git a/daemon.py b/daemon.py index dd82f995c..60cfe2562 100644 --- a/daemon.py +++ b/daemon.py @@ -4918,25 +4918,27 @@ class PubServer(BaseHTTPRequestHandler): users_path = users_path.split('/tags/')[0] actor_str = self._get_instance_url(calling_domain) + users_path tag_screen_str = actor_str + '/tags/' + hashtag + boundary = None if ' boundary=' in self.headers['Content-type']: boundary = self.headers['Content-type'].split('boundary=')[1] if ';' in boundary: boundary = boundary.split(';')[0] - # get the nickname - nickname = get_nickname_from_actor(actor_str) - editor = None - if nickname: - editor = is_editor(base_dir, nickname) - if not hashtag or not editor: - if not nickname: - print('WARN: nickname not found in ' + actor_str) - else: - print('WARN: nickname is not a moderator' + actor_str) - self._redirect_headers(tag_screen_str, cookie, calling_domain) - self.server.postreq_busy = False - return + # get the nickname + nickname = get_nickname_from_actor(actor_str) + editor = None + if nickname: + editor = is_editor(base_dir, nickname) + if not hashtag or not editor: + if not nickname: + print('WARN: nickname not found in ' + actor_str) + else: + print('WARN: nickname is not a moderator' + actor_str) + self._redirect_headers(tag_screen_str, cookie, calling_domain) + self.server.postreq_busy = False + return + if self.headers.get('Content-length'): length = int(self.headers['Content-length']) # check that the POST isn't too large @@ -4946,27 +4948,32 @@ class PubServer(BaseHTTPRequestHandler): self.server.postreq_busy = False return - try: - # read the bytes of the http form POST - post_bytes = self.rfile.read(length) - except SocketError as ex: - if ex.errno == errno.ECONNRESET: - print('EX: connection was reset while ' + - 'reading bytes from http form POST') - else: - print('EX: error while reading bytes ' + - 'from http form POST') - self.send_response(400) - self.end_headers() - self.server.postreq_busy = False - return - except ValueError as ex: - print('EX: failed to read bytes for POST, ' + str(ex)) - self.send_response(400) - self.end_headers() - self.server.postreq_busy = False - return + try: + # read the bytes of the http form POST + post_bytes = self.rfile.read(length) + except SocketError as ex: + if ex.errno == errno.ECONNRESET: + print('EX: connection was reset while ' + + 'reading bytes from http form POST') + else: + print('EX: error while reading bytes ' + + 'from http form POST') + self.send_response(400) + self.end_headers() + self.server.postreq_busy = False + return + except ValueError as ex: + print('EX: failed to read bytes for POST, ' + str(ex)) + self.send_response(400) + self.end_headers() + self.server.postreq_busy = False + return + if not boundary: + if b'--LYNX' in post_bytes: + boundary = '--LYNX' + + if boundary: # extract all of the text fields into a dict fields = \ extract_text_fields_in_post(post_bytes, boundary, debug)