mirror of https://gitlab.com/bashrc2/epicyon
POST from lynx browser
parent
17d7432fc6
commit
712beebcb8
307
daemon.py
307
daemon.py
|
@ -4739,25 +4739,28 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
users_path = path.replace('/linksdata', '')
|
users_path = path.replace('/linksdata', '')
|
||||||
users_path = users_path.replace('/editlinks', '')
|
users_path = users_path.replace('/editlinks', '')
|
||||||
actor_str = self._get_instance_url(calling_domain) + users_path
|
actor_str = self._get_instance_url(calling_domain) + users_path
|
||||||
|
|
||||||
|
boundary = None
|
||||||
if ' boundary=' in self.headers['Content-type']:
|
if ' boundary=' in self.headers['Content-type']:
|
||||||
boundary = self.headers['Content-type'].split('boundary=')[1]
|
boundary = self.headers['Content-type'].split('boundary=')[1]
|
||||||
if ';' in boundary:
|
if ';' in boundary:
|
||||||
boundary = boundary.split(';')[0]
|
boundary = boundary.split(';')[0]
|
||||||
|
|
||||||
# get the nickname
|
# get the nickname
|
||||||
nickname = get_nickname_from_actor(actor_str)
|
nickname = get_nickname_from_actor(actor_str)
|
||||||
editor = None
|
editor = None
|
||||||
if nickname:
|
if nickname:
|
||||||
editor = is_editor(base_dir, nickname)
|
editor = is_editor(base_dir, nickname)
|
||||||
if not nickname or not editor:
|
if not nickname or not editor:
|
||||||
if not nickname:
|
if not nickname:
|
||||||
print('WARN: nickname not found in ' + actor_str)
|
print('WARN: nickname not found in ' + actor_str)
|
||||||
else:
|
else:
|
||||||
print('WARN: nickname is not a moderator' + actor_str)
|
print('WARN: nickname is not a moderator' + actor_str)
|
||||||
self._redirect_headers(actor_str, cookie, calling_domain)
|
self._redirect_headers(actor_str, cookie, calling_domain)
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.headers.get('Content-length'):
|
||||||
length = int(self.headers['Content-length'])
|
length = int(self.headers['Content-length'])
|
||||||
|
|
||||||
# check that the POST isn't too large
|
# check that the POST isn't too large
|
||||||
|
@ -4767,32 +4770,37 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# read the bytes of the http form POST
|
# read the bytes of the http form POST
|
||||||
post_bytes = self.rfile.read(length)
|
post_bytes = self.rfile.read(length)
|
||||||
except SocketError as ex:
|
except SocketError as ex:
|
||||||
if ex.errno == errno.ECONNRESET:
|
if ex.errno == errno.ECONNRESET:
|
||||||
print('EX: connection was reset while ' +
|
print('EX: connection was reset while ' +
|
||||||
'reading bytes from http form POST')
|
'reading bytes from http form POST')
|
||||||
else:
|
else:
|
||||||
print('EX: error while reading bytes ' +
|
print('EX: error while reading bytes ' +
|
||||||
'from http form POST')
|
'from http form POST')
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
except ValueError as ex:
|
except ValueError as ex:
|
||||||
print('EX: failed to read bytes for POST, ' + str(ex))
|
print('EX: failed to read bytes for POST, ' + str(ex))
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
links_filename = base_dir + '/accounts/links.txt'
|
links_filename = base_dir + '/accounts/links.txt'
|
||||||
about_filename = base_dir + '/accounts/about.md'
|
about_filename = base_dir + '/accounts/about.md'
|
||||||
tos_filename = base_dir + '/accounts/tos.md'
|
tos_filename = base_dir + '/accounts/tos.md'
|
||||||
specification_filename = base_dir + '/accounts/activitypub.md'
|
specification_filename = base_dir + '/accounts/activitypub.md'
|
||||||
|
|
||||||
|
if not boundary:
|
||||||
|
if b'--LYNX' in post_bytes:
|
||||||
|
boundary = '--LYNX'
|
||||||
|
|
||||||
|
if boundary:
|
||||||
# extract all of the text fields into a dict
|
# extract all of the text fields into a dict
|
||||||
fields = \
|
fields = \
|
||||||
extract_text_fields_in_post(post_bytes, boundary, debug)
|
extract_text_fields_in_post(post_bytes, boundary, debug)
|
||||||
|
@ -4918,6 +4926,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
users_path = users_path.split('/tags/')[0]
|
users_path = users_path.split('/tags/')[0]
|
||||||
actor_str = self._get_instance_url(calling_domain) + users_path
|
actor_str = self._get_instance_url(calling_domain) + users_path
|
||||||
tag_screen_str = actor_str + '/tags/' + hashtag
|
tag_screen_str = actor_str + '/tags/' + hashtag
|
||||||
|
|
||||||
boundary = None
|
boundary = None
|
||||||
if ' boundary=' in self.headers['Content-type']:
|
if ' boundary=' in self.headers['Content-type']:
|
||||||
boundary = self.headers['Content-type'].split('boundary=')[1]
|
boundary = self.headers['Content-type'].split('boundary=')[1]
|
||||||
|
@ -5007,25 +5016,28 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
users_path = path.replace('/newswiredata', '')
|
users_path = path.replace('/newswiredata', '')
|
||||||
users_path = users_path.replace('/editnewswire', '')
|
users_path = users_path.replace('/editnewswire', '')
|
||||||
actor_str = self._get_instance_url(calling_domain) + users_path
|
actor_str = self._get_instance_url(calling_domain) + users_path
|
||||||
|
|
||||||
|
boundary = None
|
||||||
if ' boundary=' in self.headers['Content-type']:
|
if ' boundary=' in self.headers['Content-type']:
|
||||||
boundary = self.headers['Content-type'].split('boundary=')[1]
|
boundary = self.headers['Content-type'].split('boundary=')[1]
|
||||||
if ';' in boundary:
|
if ';' in boundary:
|
||||||
boundary = boundary.split(';')[0]
|
boundary = boundary.split(';')[0]
|
||||||
|
|
||||||
# get the nickname
|
# get the nickname
|
||||||
nickname = get_nickname_from_actor(actor_str)
|
nickname = get_nickname_from_actor(actor_str)
|
||||||
moderator = None
|
moderator = None
|
||||||
if nickname:
|
if nickname:
|
||||||
moderator = is_moderator(base_dir, nickname)
|
moderator = is_moderator(base_dir, nickname)
|
||||||
if not nickname or not moderator:
|
if not nickname or not moderator:
|
||||||
if not nickname:
|
if not nickname:
|
||||||
print('WARN: nickname not found in ' + actor_str)
|
print('WARN: nickname not found in ' + actor_str)
|
||||||
else:
|
else:
|
||||||
print('WARN: nickname is not a moderator' + actor_str)
|
print('WARN: nickname is not a moderator' + actor_str)
|
||||||
self._redirect_headers(actor_str, cookie, calling_domain)
|
self._redirect_headers(actor_str, cookie, calling_domain)
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.headers.get('Content-length'):
|
||||||
length = int(self.headers['Content-length'])
|
length = int(self.headers['Content-length'])
|
||||||
|
|
||||||
# check that the POST isn't too large
|
# check that the POST isn't too large
|
||||||
|
@ -5035,29 +5047,34 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# read the bytes of the http form POST
|
# read the bytes of the http form POST
|
||||||
post_bytes = self.rfile.read(length)
|
post_bytes = self.rfile.read(length)
|
||||||
except SocketError as ex:
|
except SocketError as ex:
|
||||||
if ex.errno == errno.ECONNRESET:
|
if ex.errno == errno.ECONNRESET:
|
||||||
print('EX: connection was reset while ' +
|
print('EX: connection was reset while ' +
|
||||||
'reading bytes from http form POST')
|
'reading bytes from http form POST')
|
||||||
else:
|
else:
|
||||||
print('EX: error while reading bytes ' +
|
print('EX: error while reading bytes ' +
|
||||||
'from http form POST')
|
'from http form POST')
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
except ValueError as ex:
|
except ValueError as ex:
|
||||||
print('EX: failed to read bytes for POST, ' + str(ex))
|
print('EX: failed to read bytes for POST, ' + str(ex))
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
newswire_filename = base_dir + '/accounts/newswire.txt'
|
newswire_filename = base_dir + '/accounts/newswire.txt'
|
||||||
|
|
||||||
|
if not boundary:
|
||||||
|
if b'--LYNX' in post_bytes:
|
||||||
|
boundary = '--LYNX'
|
||||||
|
|
||||||
|
if boundary:
|
||||||
# extract all of the text fields into a dict
|
# extract all of the text fields into a dict
|
||||||
fields = \
|
fields = \
|
||||||
extract_text_fields_in_post(post_bytes, boundary, debug)
|
extract_text_fields_in_post(post_bytes, boundary, debug)
|
||||||
|
@ -5276,30 +5293,33 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
users_path = path.replace('/newseditdata', '')
|
users_path = path.replace('/newseditdata', '')
|
||||||
users_path = users_path.replace('/editnewspost', '')
|
users_path = users_path.replace('/editnewspost', '')
|
||||||
actor_str = self._get_instance_url(calling_domain) + users_path
|
actor_str = self._get_instance_url(calling_domain) + users_path
|
||||||
|
|
||||||
|
boundary = None
|
||||||
if ' boundary=' in self.headers['Content-type']:
|
if ' boundary=' in self.headers['Content-type']:
|
||||||
boundary = self.headers['Content-type'].split('boundary=')[1]
|
boundary = self.headers['Content-type'].split('boundary=')[1]
|
||||||
if ';' in boundary:
|
if ';' in boundary:
|
||||||
boundary = boundary.split(';')[0]
|
boundary = boundary.split(';')[0]
|
||||||
|
|
||||||
# get the nickname
|
# get the nickname
|
||||||
nickname = get_nickname_from_actor(actor_str)
|
nickname = get_nickname_from_actor(actor_str)
|
||||||
editor_role = None
|
editor_role = None
|
||||||
if nickname:
|
if nickname:
|
||||||
editor_role = is_editor(base_dir, nickname)
|
editor_role = is_editor(base_dir, nickname)
|
||||||
if not nickname or not editor_role:
|
if not nickname or not editor_role:
|
||||||
if not nickname:
|
if not nickname:
|
||||||
print('WARN: nickname not found in ' + actor_str)
|
print('WARN: nickname not found in ' + actor_str)
|
||||||
else:
|
else:
|
||||||
print('WARN: nickname is not an editor' + actor_str)
|
print('WARN: nickname is not an editor' + actor_str)
|
||||||
if self.server.news_instance:
|
if self.server.news_instance:
|
||||||
self._redirect_headers(actor_str + '/tlfeatures',
|
self._redirect_headers(actor_str + '/tlfeatures',
|
||||||
cookie, calling_domain)
|
cookie, calling_domain)
|
||||||
else:
|
else:
|
||||||
self._redirect_headers(actor_str + '/tlnews',
|
self._redirect_headers(actor_str + '/tlnews',
|
||||||
cookie, calling_domain)
|
cookie, calling_domain)
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.headers.get('Content-length'):
|
||||||
length = int(self.headers['Content-length'])
|
length = int(self.headers['Content-length'])
|
||||||
|
|
||||||
# check that the POST isn't too large
|
# check that the POST isn't too large
|
||||||
|
@ -5314,27 +5334,32 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# read the bytes of the http form POST
|
# read the bytes of the http form POST
|
||||||
post_bytes = self.rfile.read(length)
|
post_bytes = self.rfile.read(length)
|
||||||
except SocketError as ex:
|
except SocketError as ex:
|
||||||
if ex.errno == errno.ECONNRESET:
|
if ex.errno == errno.ECONNRESET:
|
||||||
print('EX: connection was reset while ' +
|
print('EX: connection was reset while ' +
|
||||||
'reading bytes from http form POST')
|
'reading bytes from http form POST')
|
||||||
else:
|
else:
|
||||||
print('EX: error while reading bytes ' +
|
print('EX: error while reading bytes ' +
|
||||||
'from http form POST')
|
'from http form POST')
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
except ValueError as ex:
|
except ValueError as ex:
|
||||||
print('EX: failed to read bytes for POST, ' + str(ex))
|
print('EX: failed to read bytes for POST, ' + str(ex))
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not boundary:
|
||||||
|
if b'--LYNX' in post_bytes:
|
||||||
|
boundary = '--LYNX'
|
||||||
|
|
||||||
|
if boundary:
|
||||||
# extract all of the text fields into a dict
|
# extract all of the text fields into a dict
|
||||||
fields = \
|
fields = \
|
||||||
extract_text_fields_in_post(post_bytes, boundary, debug)
|
extract_text_fields_in_post(post_bytes, boundary, debug)
|
||||||
|
@ -5416,19 +5441,22 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
users_path = path.replace('/profiledata', '')
|
users_path = path.replace('/profiledata', '')
|
||||||
users_path = users_path.replace('/editprofile', '')
|
users_path = users_path.replace('/editprofile', '')
|
||||||
actor_str = self._get_instance_url(calling_domain) + users_path
|
actor_str = self._get_instance_url(calling_domain) + users_path
|
||||||
|
|
||||||
|
boundary = None
|
||||||
if ' boundary=' in self.headers['Content-type']:
|
if ' boundary=' in self.headers['Content-type']:
|
||||||
boundary = self.headers['Content-type'].split('boundary=')[1]
|
boundary = self.headers['Content-type'].split('boundary=')[1]
|
||||||
if ';' in boundary:
|
if ';' in boundary:
|
||||||
boundary = boundary.split(';')[0]
|
boundary = boundary.split(';')[0]
|
||||||
|
|
||||||
# get the nickname
|
# get the nickname
|
||||||
nickname = get_nickname_from_actor(actor_str)
|
nickname = get_nickname_from_actor(actor_str)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
print('WARN: nickname not found in ' + actor_str)
|
print('WARN: nickname not found in ' + actor_str)
|
||||||
self._redirect_headers(actor_str, cookie, calling_domain)
|
self._redirect_headers(actor_str, cookie, calling_domain)
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.headers.get('Content-length'):
|
||||||
length = int(self.headers['Content-length'])
|
length = int(self.headers['Content-length'])
|
||||||
|
|
||||||
# check that the POST isn't too large
|
# check that the POST isn't too large
|
||||||
|
@ -5439,29 +5467,34 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# read the bytes of the http form POST
|
# read the bytes of the http form POST
|
||||||
post_bytes = self.rfile.read(length)
|
post_bytes = self.rfile.read(length)
|
||||||
except SocketError as ex:
|
except SocketError as ex:
|
||||||
if ex.errno == errno.ECONNRESET:
|
if ex.errno == errno.ECONNRESET:
|
||||||
print('EX: connection was reset while ' +
|
print('EX: connection was reset while ' +
|
||||||
'reading bytes from http form POST')
|
'reading bytes from http form POST')
|
||||||
else:
|
else:
|
||||||
print('EX: error while reading bytes ' +
|
print('EX: error while reading bytes ' +
|
||||||
'from http form POST')
|
'from http form POST')
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
except ValueError as ex:
|
except ValueError as ex:
|
||||||
print('EX: failed to read bytes for POST, ' + str(ex))
|
print('EX: failed to read bytes for POST, ' + str(ex))
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
admin_nickname = get_config_param(self.server.base_dir, 'admin')
|
admin_nickname = get_config_param(self.server.base_dir, 'admin')
|
||||||
|
|
||||||
|
if not boundary:
|
||||||
|
if b'--LYNX' in post_bytes:
|
||||||
|
boundary = '--LYNX'
|
||||||
|
|
||||||
|
if boundary:
|
||||||
# get the various avatar, banner and background images
|
# get the various avatar, banner and background images
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
profile_media_types = (
|
profile_media_types = (
|
||||||
|
|
Loading…
Reference in New Issue