fix: weird encryption with editing unencrypted pastes

This commit is contained in:
Floorb 2023-06-13 18:28:20 -04:00
parent f2efc54d0a
commit ca28f037f7
2 changed files with 12 additions and 6 deletions

View file

@ -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);

View file

@ -61,7 +61,7 @@
<!-- Text area -->
<textarea class="textarea" rows="15" id="code" name="paste_data" onkeyup="countChars(this);"
onkeydown="return catchTab(this,event)"
placeholder="Paste Or Drop Text File Here."><?php echo (isset($_POST['paste_data'])) ? pp_html_escape($_POST['paste_data']) : ''; ?></textarea>
placeholder="Paste or drop text file here."><?php echo (isset($_POST['paste_data'])) ? pp_html_escape($_POST['paste_data']) : ''; ?></textarea>
<p id="charNum"><b>File Size: </b><span style="color: green;">1000/1000Kb</span></p>
<!-- Tag system -->