mirror of
https://github.com/onionshare/onionshare.git
synced 2025-12-15 08:19:08 -05:00
Merge branch 'develop' into add_security_headers
This commit is contained in:
commit
eeacd8c507
69 changed files with 922 additions and 522 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
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -90,7 +94,7 @@ class ReceiveModeWeb:
|
|||
title=self.web.settings.get("general", "title")
|
||||
)
|
||||
|
||||
@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
|
||||
|
|
@ -221,7 +225,7 @@ class ReceiveModeWeb:
|
|||
title=self.web.settings.get("general", "title"),
|
||||
)
|
||||
|
||||
@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()
|
||||
|
||||
|
|
@ -207,10 +211,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.
|
||||
|
|
@ -159,7 +159,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.
|
||||
|
|
|
|||
|
|
@ -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