fixing server interaction in JS, simple pastes now work

This commit is contained in:
El RIDO 2019-05-11 10:39:42 +02:00
parent 5b3286df4d
commit 788ea67b49
No known key found for this signature in database
GPG Key ID: 0F5C940A6BD81F92
3 changed files with 20 additions and 11 deletions

View File

@ -3710,11 +3710,10 @@ jQuery.PrivateBin = (function($, RawDeflate) {
*/
me.run = function()
{
$.ajax({
type: data ? 'POST' : 'GET',
let isPost = Object.keys(data).length > 0,
ajaxParams = {
type: isPost ? 'POST' : 'GET',
url: url,
data: data,
dataType: 'json',
headers: ajaxHeaders,
success: function(result) {
if (result.status === 0) {
@ -3725,8 +3724,17 @@ jQuery.PrivateBin = (function($, RawDeflate) {
fail(2, result);
}
}
})
.fail(function(jqXHR, textStatus, errorThrown) {
};
if (isPost) {
ajaxParams.data = data;
['adata', 'meta'].map(function (key) {
if (data.hasOwnProperty(key)) {
ajaxParams.data[key] = JSON.stringify(data[key]);
}
});
ajaxParams.dataType = 'json';
}
$.ajax(ajaxParams).fail(function(jqXHR, textStatus, errorThrown) {
console.error(textStatus, errorThrown);
fail(3, jqXHR);
});
@ -4186,7 +4194,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
{
const pastePlain = await decryptOrPromptPassword(
key, password,
paste.hasOwnProperty('ct') ? paste.ct : paste.data
paste.hasOwnProperty('ct') ? [paste.ct, paste.adata] : paste.data
);
if (pastePlain === false) {
if (password.length === 0) {
@ -4347,6 +4355,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
.catch((err) => {
// wait for the user to type in the password,
// then PasteDecrypter.run will be called again
console.log(decryptionPromises);
});
};

View File

@ -55,7 +55,7 @@ if ($ZEROBINCOMPATIBILITY):
<?php
endif;
?>
<script type="text/javascript" data-cfasync="false" src="js/zlib-1.2.11.js" integrity="sha512-h8gJuMJ1L95FlbJwo5F8NkjEpK0Nv+9ASHShUrCBnMpIlciQ0d0qfkmAKYJ1jlwfqrbVYhqr8hpyIh5wClIP3w==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/zlib-1.2.11.js" integrity="sha512-Yey/0yoaVmSbqMEyyff3DIu8kCPwpHvHf7tY1AuZ1lrX9NPCMg87PwzngMi+VNbe4ilCApmePeuKT869RTcyCQ==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/rawinflate-0.3.js" integrity="sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/bootstrap-3.3.7.js" integrity="sha512-iztkobsvnjKfAtTNdHkGVjAYTrrtlC7mGp/54c40wowO7LhURYl3gVzzcEqGl/qKXQltJ2HwMrdLcNUdo+N/RQ==" crossorigin="anonymous"></script>
<?php
@ -71,7 +71,7 @@ if ($MARKDOWN):
endif;
?>
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-nqFl6ezAinqULcBBqWHuJ03J3SQZ0zFhHAgDX/7Vr0x9eNWdkqNvoArOrdvi5yZm45TyG+vuQNkLCHh+qhcOXw==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-AakQFf2/uSst5PDZhgmWj0qEBmhVz32MXLeWygymJ/Mhi4g+Zk/jrY4aDahVSi6BCqGZqswXOhnbikofr+leOQ==" 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]-->

View File

@ -34,7 +34,7 @@ if ($ZEROBINCOMPATIBILITY):
<?php
endif;
?>
<script type="text/javascript" data-cfasync="false" src="js/zlib-1.2.11.js" integrity="sha512-h8gJuMJ1L95FlbJwo5F8NkjEpK0Nv+9ASHShUrCBnMpIlciQ0d0qfkmAKYJ1jlwfqrbVYhqr8hpyIh5wClIP3w==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/zlib-1.2.11.js" integrity="sha512-Yey/0yoaVmSbqMEyyff3DIu8kCPwpHvHf7tY1AuZ1lrX9NPCMg87PwzngMi+VNbe4ilCApmePeuKT869RTcyCQ==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/rawinflate-0.3.js" integrity="sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==" crossorigin="anonymous"></script>
<?php
if ($SYNTAXHIGHLIGHTING):
@ -49,7 +49,7 @@ if ($MARKDOWN):
endif;
?>
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-nqFl6ezAinqULcBBqWHuJ03J3SQZ0zFhHAgDX/7Vr0x9eNWdkqNvoArOrdvi5yZm45TyG+vuQNkLCHh+qhcOXw==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-AakQFf2/uSst5PDZhgmWj0qEBmhVz32MXLeWygymJ/Mhi4g+Zk/jrY4aDahVSi6BCqGZqswXOhnbikofr+leOQ==" 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]-->