Skip to content

Commit

Permalink
Merge pull request #1 from luk1337/luk/fixup
Browse files Browse the repository at this point in the history
luk1337: minor fixups
  • Loading branch information
zhaobenny committed Jan 17, 2024
2 parents 6503949 + 3b0c025 commit abbbd50
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/endpoints/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub async fn create(
extension: String::from(""),
private: false,
readonly: false,
editable: true,
editable: ARGS.editable,
encrypt_server: false,
encrypted_key: Some(String::from("")),
encrypt_client: false,
Expand Down
2 changes: 1 addition & 1 deletion templates/auth_admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% include "footer.html" %} {% if !args.pure_html %}
<style>
#auth-form {
background-color: #f7f7f7;
background-color: var(--background-alt);
border-radius: 6px;
padding: 10px;
width: fit-content;
Expand Down
2 changes: 1 addition & 1 deletion templates/auth_upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
{% include "footer.html" %} {% if !args.pure_html %}
<style>
#auth-form {
background-color: #f7f7f7;
background-color: var(--background-alt);
border-radius: 6px;
padding: 10px;
width: fit-content;
Expand Down
10 changes: 9 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
<input type="hidden" name="syntax_highlight" value="none">
{%- endif %}

{% if args.encryption_client_side || args.encryption_server_side || args.enable_readonly || args.private %}
<div>
<label for="syntax_highlight">Privacy <sup> <a href="{{ args.public_path_as_str() }}/guide#privacy"></a></sup></label><br>
<select style="width: 100%;" name="privacy" id="privacy">
Expand All @@ -167,6 +168,7 @@
{%- endif %}
</select>
</div>
{%- endif %}

{% if args.encryption_client_side || args.encryption_server_side || args.enable_readonly %}
<div>
Expand Down Expand Up @@ -237,7 +239,9 @@

// {% if args.encryption_client_side || args.encryption_server_side || args.enable_readonly %}
if (passwordField.value.trim() != "") {
// {% if !args.no_file_upload %}
if (fileOversized()) return false;
// {%- endif %}

if (privacyDropdown.value == "secret") {
let randomKey = Array.from(Array(16), () => Math.floor(Math.random() * 36).toString(36)).join('');
Expand All @@ -249,7 +253,9 @@
content.value = contentInput.value;
}
hiddenPlainKeyField.name = "";
// {% if !args.no_file_upload %}
await encryptFile();
// {%- endif %}
} else {
hiddenPlainKeyField.value = passwordField.value;
hiddenEncryptedClientSide.name = "";
Expand All @@ -270,7 +276,7 @@
content.value = contentInput.value;
// {%- endif %}

if (contentInput.value.trim() == "" && hiddenFileButton.files.length == 0) {
if (contentInput.value.trim() == "" && (hiddenFileButton == undefined || hiddenFileButton.files.length == 0)) {
contentInput.focus();
return false;
}
Expand Down Expand Up @@ -316,6 +322,7 @@
return aesjs.utils.hex.fromBytes(encryptedBytes);
}

// {% if !args.no_file_upload %}
function encryptFileWithPassword(password, bytes) {
const passwordBytes = aesjs.utils.utf8.toBytes(password.padStart(32, "#"));
const aesCtr = new aesjs.ModeOfOperation.ctr(passwordBytes);
Expand Down Expand Up @@ -392,6 +399,7 @@
attachFileButton.textContent = "Attached: " + hiddenFileButton.files[0].name;
evt.preventDefault();
};
// {%- endif %}

document.onpaste = function (event) {
const data = (event.clipboardData || event.originalEvent.clipboardData);
Expand Down

0 comments on commit abbbd50

Please sign in to comment.