mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-02 06:26:10 -04:00
merge develop branch into client_auth_v3 branch and use our forked stem which works with poetry
This commit is contained in:
commit
b43e7fee13
125 changed files with 2375 additions and 1361 deletions
|
@ -250,7 +250,7 @@ class Common:
|
|||
)
|
||||
left_spaces = (43 - len(self.version) - 1) // 2
|
||||
right_spaces = left_spaces
|
||||
if left_spaces + len(self.version) + right_spaces < 43:
|
||||
if left_spaces + len(self.version) + 1 + right_spaces < 43:
|
||||
right_spaces += 1
|
||||
print(
|
||||
Back.MAGENTA
|
||||
|
|
|
@ -229,6 +229,7 @@ ul.breadcrumbs li a:link, ul.breadcrumbs li a:visited {
|
|||
display: block;
|
||||
}
|
||||
.chat-wrapper .message {
|
||||
word-break: break-word;
|
||||
font-weight: normal;
|
||||
display: block;
|
||||
margin-bottom: 0.3em;
|
||||
|
|
|
@ -88,7 +88,7 @@ var emitMessage = function (socket) {
|
|||
|
||||
var updateUsername = function (socket) {
|
||||
var username = $('#username').val();
|
||||
if (!checkUsernameExists(username)) {
|
||||
if (!checkUsernameExists(username) && !checkUsernameTooLong(username)) {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: `http://${document.domain}:${location.port}/update-session-username`,
|
||||
|
@ -133,6 +133,15 @@ var checkUsernameExists = function (username) {
|
|||
return false;
|
||||
}
|
||||
|
||||
var checkUsernameTooLong = function (username) {
|
||||
$('#username-error').text('');
|
||||
if (username.length > 128) {
|
||||
$('#username-error').text('Please choose a shorter username.');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
var getScrollDiffBefore = function () {
|
||||
return $('#chat').scrollTop() - ($('#chat')[0].scrollHeight - $('#chat')[0].offsetHeight);
|
||||
}
|
||||
|
|
21
cli/onionshare_cli/resources/templates/500.html
Normal file
21
cli/onionshare_cli/resources/templates/500.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>OnionShare: An error occurred</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="{{ static_url_path }}/img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="stylesheet" rel="subresource" type="text/css" href="{{ static_url_path }}/css/style.css" media="all">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="info-wrapper">
|
||||
<div class="info">
|
||||
<p><img class="logo" src="{{ static_url_path }}/img/logo_large.png" title="OnionShare"></p>
|
||||
<p class="info-header">Sorry, an unexpected error seems to have occurred, and your request didn't succeed.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -23,6 +23,7 @@
|
|||
<div class="chat-container no-js">
|
||||
<div class="chat-users">
|
||||
<div class="editable-username">
|
||||
<label for="username">Your username:</label>
|
||||
<input id="username" value="{{ username }}" />
|
||||
<p id="username-error"></p>
|
||||
</div>
|
||||
|
@ -43,4 +44,4 @@
|
|||
<script async src="{{ static_url_path }}/js/chat.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -1 +1 @@
|
|||
2.3.2.dev1
|
||||
2.3.3
|
|
@ -75,6 +75,7 @@ class Settings(object):
|
|||
"it": "Italiano", # Italian
|
||||
"ja": "日本語", # Japanese
|
||||
"ckb": "Soranî", # Kurdish (Central)
|
||||
"lt": "Lietuvių Kalba", # Lithuanian
|
||||
"nb_NO": "Norsk Bokmål", # Norwegian Bokmål
|
||||
# "fa": "فارسی", # Persian
|
||||
"pl": "Polski", # Polish
|
||||
|
@ -110,6 +111,7 @@ class Settings(object):
|
|||
"tor_bridges_use_custom_bridges": "",
|
||||
"persistent_tabs": [],
|
||||
"locale": None, # this gets defined in fill_in_defaults()
|
||||
"theme": 0,
|
||||
}
|
||||
self._settings = {}
|
||||
self.fill_in_defaults()
|
||||
|
|
|
@ -39,6 +39,12 @@ class ChatModeWeb:
|
|||
# This tracks the history id
|
||||
self.cur_history_id = 0
|
||||
|
||||
# Whether or not we can send REQUEST_INDIVIDUAL_FILE_STARTED
|
||||
# and maybe other events when requests come in to this mode
|
||||
# Chat mode has no concept of individual file requests that
|
||||
# turn into history widgets in the GUI, so set it to False
|
||||
self.supports_file_requests = False
|
||||
|
||||
self.define_routes()
|
||||
|
||||
def define_routes(self):
|
||||
|
@ -46,7 +52,7 @@ class ChatModeWeb:
|
|||
The web app routes for chatting
|
||||
"""
|
||||
|
||||
@self.web.app.route("/")
|
||||
@self.web.app.route("/", methods=["GET"], provide_automatic_options=False)
|
||||
def index():
|
||||
history_id = self.cur_history_id
|
||||
self.cur_history_id += 1
|
||||
|
@ -72,27 +78,40 @@ class ChatModeWeb:
|
|||
)
|
||||
return self.web.add_security_headers(r)
|
||||
|
||||
@self.web.app.route("/update-session-username", methods=["POST"])
|
||||
@self.web.app.route("/update-session-username", methods=["POST"], provide_automatic_options=False)
|
||||
def update_session_username():
|
||||
history_id = self.cur_history_id
|
||||
data = request.get_json()
|
||||
if (
|
||||
data.get("username", "")
|
||||
and data.get("username", "") not in self.connected_users
|
||||
and len(data.get("username", "")) < 128
|
||||
):
|
||||
session["name"] = data.get("username", session.get("name"))
|
||||
self.web.add_request(
|
||||
request.path,
|
||||
{"id": history_id, "status_code": 200},
|
||||
)
|
||||
|
||||
self.web.add_request(self.web.REQUEST_LOAD, request.path)
|
||||
r = make_response(
|
||||
jsonify(
|
||||
username=session.get("name"),
|
||||
success=True,
|
||||
self.web.add_request(
|
||||
request.path,
|
||||
{"id": history_id, "status_code": 200},
|
||||
)
|
||||
|
||||
self.web.add_request(self.web.REQUEST_LOAD, request.path)
|
||||
r = make_response(
|
||||
jsonify(
|
||||
username=session.get("name"),
|
||||
success=True,
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.web.add_request(
|
||||
request.path,
|
||||
{"id": history_id, "status_code": 403},
|
||||
)
|
||||
|
||||
r = make_response(
|
||||
jsonify(
|
||||
username=session.get("name"),
|
||||
success=False,
|
||||
)
|
||||
)
|
||||
)
|
||||
return self.web.add_security_headers(r)
|
||||
|
||||
@self.web.socketio.on("joined", namespace="/chat")
|
||||
|
|
|
@ -64,6 +64,10 @@ class ReceiveModeWeb:
|
|||
# This tracks the history id
|
||||
self.cur_history_id = 0
|
||||
|
||||
# Whether or not we can send REQUEST_INDIVIDUAL_FILE_STARTED
|
||||
# and maybe other events when requests come in to this mode
|
||||
self.supports_file_requests = True
|
||||
|
||||
self.define_routes()
|
||||
|
||||
def define_routes(self):
|
||||
|
@ -71,7 +75,7 @@ class ReceiveModeWeb:
|
|||
The web app routes for receiving files
|
||||
"""
|
||||
|
||||
@self.web.app.route("/")
|
||||
@self.web.app.route("/", methods=["GET"], provide_automatic_options=False)
|
||||
def index():
|
||||
history_id = self.cur_history_id
|
||||
self.cur_history_id += 1
|
||||
|
@ -93,7 +97,7 @@ class ReceiveModeWeb:
|
|||
)
|
||||
return self.web.add_security_headers(r)
|
||||
|
||||
@self.web.app.route("/upload", methods=["POST"])
|
||||
@self.web.app.route("/upload", methods=["POST"], provide_automatic_options=False)
|
||||
def upload(ajax=False):
|
||||
"""
|
||||
Handle the upload files POST request, though at this point, the files have
|
||||
|
@ -225,7 +229,7 @@ class ReceiveModeWeb:
|
|||
)
|
||||
return self.web.add_security_headers(r)
|
||||
|
||||
@self.web.app.route("/upload-ajax", methods=["POST"])
|
||||
@self.web.app.route("/upload-ajax", methods=["POST"], provide_automatic_options=False)
|
||||
def upload_ajax_public():
|
||||
if not self.can_upload:
|
||||
return self.web.error403()
|
||||
|
|
|
@ -52,6 +52,10 @@ class SendBaseModeWeb:
|
|||
# This tracks the history id
|
||||
self.cur_history_id = 0
|
||||
|
||||
# Whether or not we can send REQUEST_INDIVIDUAL_FILE_STARTED
|
||||
# and maybe other events when requests come in to this mode
|
||||
self.supports_file_requests = True
|
||||
|
||||
self.define_routes()
|
||||
self.init()
|
||||
|
||||
|
@ -208,10 +212,6 @@ class SendBaseModeWeb:
|
|||
history_id = self.cur_history_id
|
||||
self.cur_history_id += 1
|
||||
|
||||
# Only GET requests are allowed, any other method should fail
|
||||
if request.method != "GET":
|
||||
return self.web.error405(history_id)
|
||||
|
||||
self.web.add_request(
|
||||
self.web.REQUEST_INDIVIDUAL_FILE_STARTED,
|
||||
path,
|
||||
|
|
|
@ -134,8 +134,8 @@ class ShareModeWeb(SendBaseModeWeb):
|
|||
The web app routes for sharing files
|
||||
"""
|
||||
|
||||
@self.web.app.route("/", defaults={"path": ""})
|
||||
@self.web.app.route("/<path:path>")
|
||||
@self.web.app.route("/", defaults={"path": ""}, methods=["GET"], provide_automatic_options=False)
|
||||
@self.web.app.route("/<path:path>", methods=["GET"], provide_automatic_options=False)
|
||||
def index(path):
|
||||
"""
|
||||
Render the template for the onionshare landing page.
|
||||
|
@ -160,7 +160,7 @@ class ShareModeWeb(SendBaseModeWeb):
|
|||
|
||||
return self.render_logic(path)
|
||||
|
||||
@self.web.app.route("/download")
|
||||
@self.web.app.route("/download", methods=["GET"], provide_automatic_options=False)
|
||||
def download():
|
||||
"""
|
||||
Download the zip file.
|
||||
|
|
|
@ -191,7 +191,6 @@ class Web:
|
|||
self.app.static_url_path = self.static_url_path
|
||||
self.app.add_url_rule(
|
||||
self.static_url_path + "/<path:filename>",
|
||||
endpoint="static",
|
||||
view_func=self.app.send_static_file,
|
||||
)
|
||||
|
||||
|
@ -229,6 +228,20 @@ class Web:
|
|||
mode.cur_history_id += 1
|
||||
return self.error404(history_id)
|
||||
|
||||
@self.app.errorhandler(405)
|
||||
def method_not_allowed(e):
|
||||
mode = self.get_mode()
|
||||
history_id = mode.cur_history_id
|
||||
mode.cur_history_id += 1
|
||||
return self.error405(history_id)
|
||||
|
||||
@self.app.errorhandler(500)
|
||||
def method_not_allowed(e):
|
||||
mode = self.get_mode()
|
||||
history_id = mode.cur_history_id
|
||||
mode.cur_history_id += 1
|
||||
return self.error500(history_id)
|
||||
|
||||
@self.app.route("/<password_candidate>/shutdown")
|
||||
def shutdown(password_candidate):
|
||||
"""
|
||||
|
@ -280,11 +293,13 @@ class Web:
|
|||
return self.add_security_headers(r)
|
||||
|
||||
def error404(self, history_id):
|
||||
self.add_request(
|
||||
self.REQUEST_INDIVIDUAL_FILE_STARTED,
|
||||
request.path,
|
||||
{"id": history_id, "status_code": 404},
|
||||
)
|
||||
mode = self.get_mode()
|
||||
if mode.supports_file_requests:
|
||||
self.add_request(
|
||||
self.REQUEST_INDIVIDUAL_FILE_STARTED,
|
||||
request.path,
|
||||
{"id": history_id, "status_code": 404},
|
||||
)
|
||||
|
||||
self.add_request(Web.REQUEST_OTHER, request.path)
|
||||
r = make_response(
|
||||
|
@ -293,11 +308,13 @@ class Web:
|
|||
return self.add_security_headers(r)
|
||||
|
||||
def error405(self, history_id):
|
||||
self.add_request(
|
||||
self.REQUEST_INDIVIDUAL_FILE_STARTED,
|
||||
request.path,
|
||||
{"id": history_id, "status_code": 405},
|
||||
)
|
||||
mode = self.get_mode()
|
||||
if mode.supports_file_requests:
|
||||
self.add_request(
|
||||
self.REQUEST_INDIVIDUAL_FILE_STARTED,
|
||||
request.path,
|
||||
{"id": history_id, "status_code": 405},
|
||||
)
|
||||
|
||||
self.add_request(Web.REQUEST_OTHER, request.path)
|
||||
r = make_response(
|
||||
|
@ -305,6 +322,21 @@ class Web:
|
|||
)
|
||||
return self.add_security_headers(r)
|
||||
|
||||
def error500(self, history_id):
|
||||
mode = self.get_mode()
|
||||
if mode.supports_file_requests:
|
||||
self.add_request(
|
||||
self.REQUEST_INDIVIDUAL_FILE_STARTED,
|
||||
request.path,
|
||||
{"id": history_id, "status_code": 500},
|
||||
)
|
||||
|
||||
self.add_request(Web.REQUEST_OTHER, request.path)
|
||||
r = make_response(
|
||||
render_template("500.html", static_url_path=self.static_url_path), 500
|
||||
)
|
||||
return self.add_security_headers(r)
|
||||
|
||||
def add_security_headers(self, r):
|
||||
"""
|
||||
Add security headers to a request
|
||||
|
|
|
@ -37,8 +37,8 @@ class WebsiteModeWeb(SendBaseModeWeb):
|
|||
The web app routes for sharing a website
|
||||
"""
|
||||
|
||||
@self.web.app.route("/", defaults={"path": ""})
|
||||
@self.web.app.route("/<path:path>")
|
||||
@self.web.app.route("/", defaults={"path": ""}, methods=["GET"], provide_automatic_options=False)
|
||||
@self.web.app.route("/<path:path>", methods=["GET"], provide_automatic_options=False)
|
||||
def path_public(path):
|
||||
return path_logic(path)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue