Fix attachment issues
Fixes https://github.com/PrivateBin/PrivateBin/issues/315 The attachment viewer is also used for storing to be uploaded attachments, which caused some confusion in handling them. I also tried to add some comments clarifying it as it seems to work. Additionally I fixed the issue that you could submit an empty paste and it was not rejected.
This commit is contained in:
parent
db7c7e2e16
commit
da45d347e2
4 changed files with 27 additions and 6 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,7 +1,9 @@
|
|||
# Ignore server files for safety
|
||||
.htaccess
|
||||
.htpasswd
|
||||
cfg/conf.php
|
||||
cfg/*
|
||||
!cfg/conf.sample.php
|
||||
!cfg/.htaccess
|
||||
|
||||
# Ignore data/
|
||||
data/
|
||||
|
|
|
@ -2005,6 +2005,19 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
|
|||
$attachmentLink.off('click');
|
||||
$attachmentPreview.html('');
|
||||
|
||||
AttachmentViewer.removeAttachmentData();
|
||||
};
|
||||
|
||||
/**
|
||||
* removes the attachment data
|
||||
*
|
||||
* This removes the data, which would be uploaded otherwise.
|
||||
*
|
||||
* @name AttachmentViewer.removeAttachmentData
|
||||
* @function
|
||||
*/
|
||||
me.removeAttachmentData = function()
|
||||
{
|
||||
file = undefined;
|
||||
attachmentData = undefined;
|
||||
};
|
||||
|
@ -2038,7 +2051,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
|
|||
};
|
||||
|
||||
/**
|
||||
* checks if there is an attachment
|
||||
* checks if there is an attachment displayed
|
||||
*
|
||||
* @name AttachmentViewer.hasAttachment
|
||||
* @function
|
||||
|
@ -2053,7 +2066,9 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
|
|||
};
|
||||
|
||||
/**
|
||||
* checks if there is attachment data available
|
||||
* checks if there is attachment data (for preview!) available
|
||||
*
|
||||
* It returns true, when there is data that needs to be encrypted.
|
||||
*
|
||||
* @name AttachmentViewer.hasAttachmentData
|
||||
* @function
|
||||
|
@ -2824,6 +2839,9 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
|
|||
$fileWrap.removeClass('hidden');
|
||||
}
|
||||
|
||||
// in any case, remove saved attachment data
|
||||
AttachmentViewer.removeAttachmentData();
|
||||
|
||||
// our up-to-date jQuery can handle it :)
|
||||
$fileWrap.find('input').val('');
|
||||
|
||||
|
@ -3696,10 +3714,11 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
|
|||
// get data
|
||||
var plainText = Editor.getText(),
|
||||
format = PasteViewer.getFormat(),
|
||||
// the methods may return different values if no files are attached (null, undefined or false)
|
||||
files = TopNav.getFileList() || AttachmentViewer.getFile() || AttachmentViewer.hasAttachment();
|
||||
|
||||
// do not send if there is no data
|
||||
if (plainText.length === 0 && files === null) {
|
||||
if (plainText.length === 0 && !files) {
|
||||
// revert loading status…
|
||||
Alert.hideLoading();
|
||||
TopNav.showCreateButtons();
|
||||
|
|
|
@ -75,7 +75,7 @@ if ($MARKDOWN):
|
|||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-5MEpLVeCKou7sL5U7X8uo5O0CG+1+aLGpN2O5Xvo9e31Ql7/7N8X03OCcwqBNEKv61IcSlxkCP9eLXZl8eMeBA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-mJnXRlEN4mKPZWcq3Vwsql3hHa8X9EqsePjAGKadlbD4gF5m7MhwCreA9LQ/SOfoVGQQWG5xgTiuPEXLzs1D2g==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
|
|
@ -54,7 +54,7 @@ if ($QRCODE):
|
|||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-5MEpLVeCKou7sL5U7X8uo5O0CG+1+aLGpN2O5Xvo9e31Ql7/7N8X03OCcwqBNEKv61IcSlxkCP9eLXZl8eMeBA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-mJnXRlEN4mKPZWcq3Vwsql3hHa8X9EqsePjAGKadlbD4gF5m7MhwCreA9LQ/SOfoVGQQWG5xgTiuPEXLzs1D2g==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
|
Loading…
Reference in a new issue