mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-05-02 14:36:08 -04:00
fixing urlshortening regression caused by CSP introduction, resolves #10
This commit is contained in:
parent
cd02c6e916
commit
47646e056b
7 changed files with 33 additions and 11 deletions
|
@ -536,6 +536,16 @@ $(function() {
|
|||
*/
|
||||
headers: {'X-Requested-With': 'JSONHttpRequest'},
|
||||
|
||||
/**
|
||||
* URL shortners create address
|
||||
*/
|
||||
shortenerUrl: '',
|
||||
|
||||
/**
|
||||
* URL of newly created paste
|
||||
*/
|
||||
createdPasteUrl: '',
|
||||
|
||||
/**
|
||||
* Get the current script location (without search or hash part of the URL).
|
||||
* eg. http://server.com/zero/?aaaa#bbbb --> http://server.com/zero/
|
||||
|
@ -1077,6 +1087,10 @@ $(function() {
|
|||
url, url
|
||||
) + privatebin.shortenUrl(url)
|
||||
);
|
||||
var shortenButton = $('#shortenbutton');
|
||||
if (shortenButton) {
|
||||
shortenButton.click($.proxy(privatebin.sendToShortener, privatebin));
|
||||
}
|
||||
$('#deletelink').html('<a href="' + deleteUrl + '">' + i18n._('Delete data') + '</a>');
|
||||
privatebin.pasteResult.removeClass('hidden');
|
||||
// We pre-select the link so that the user only has to [Ctrl]+[c] the link.
|
||||
|
@ -1110,11 +1124,8 @@ $(function() {
|
|||
{
|
||||
var shortenerHtml = $('#shortenbutton');
|
||||
if (shortenerHtml) {
|
||||
var shortener = shortenerHtml.data('shortener');
|
||||
shortenerHtml.attr(
|
||||
'onclick',
|
||||
"window.location.href = '" + shortener + encodeURIComponent(url) + "';"
|
||||
);
|
||||
this.shortenerUrl = shortenerHtml.data('shortener');
|
||||
this.createdPasteUrl = url;
|
||||
return ' ' + $('<div />').append(shortenerHtml.clone()).html();
|
||||
}
|
||||
return '';
|
||||
|
@ -1219,6 +1230,17 @@ $(function() {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Forward to URL shortener.
|
||||
*
|
||||
* @param Event event
|
||||
*/
|
||||
sendToShortener: function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
window.location.href = this.shortenerUrl + encodeURIComponent(this.createdPasteUrl);
|
||||
},
|
||||
|
||||
/**
|
||||
* Reload the page.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue