From ca28f037f74354b9b23f51c8aa6a054b0228a782 Mon Sep 17 00:00:00 2001 From: Floorb <132411956+Neetpone@users.noreply.github.com> Date: Tue, 13 Jun 2023 18:28:20 -0400 Subject: [PATCH] fix: weird encryption with editing unencrypted pastes --- public/index.php | 16 +++++++++++----- theme/bulma/main.php | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/public/index.php b/public/index.php index d21ec45..38ae4ae 100644 --- a/public/index.php +++ b/public/index.php @@ -126,11 +126,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $paste_password = password_hash($paste_password, PASSWORD_DEFAULT); } - $paste_content = openssl_encrypt( - $_POST['paste_data'], - PP_ENCRYPTION_ALGO, - PP_ENCRYPTION_KEY - ); + // If it's a new paste or the existing paste is encrypted, encrypt the paste + // This is to prevent legacy pastes from getting weird + if ($editing && !$paste->encrypt) { + $paste_content = $_POST['paste_data']; + } else { + $paste_content = openssl_encrypt( + $_POST['paste_data'], + PP_ENCRYPTION_ALGO, + PP_ENCRYPTION_KEY + ); + } // Set expiry time $expires = calculatePasteExpiry($p_expiry); diff --git a/theme/bulma/main.php b/theme/bulma/main.php index 6a47dd7..d525cde 100644 --- a/theme/bulma/main.php +++ b/theme/bulma/main.php @@ -61,7 +61,7 @@ + placeholder="Paste or drop text file here.">
File Size: 1000/1000Kb