made phpUnit and most mocha tests work again, had to remove some injected objects and added a helper method to facilitate a cache reset for the unit tests. Page template is still broken and the JS test for baseUri() fails

pull/180/head
El RIDO 7 years ago
parent e880f7924c
commit 131e08ca33
No known key found for this signature in database
GPG Key ID: 0F5C940A6BD81F92

@ -104,7 +104,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
v = Math.floor(seconds / (60 * 60 * 24 * 30)); v = Math.floor(seconds / (60 * 60 * 24 * 30));
return [v, 'month']; return [v, 'month'];
}; }
/** /**
* checks if a string is valid text (and not onyl whitespace) * checks if a string is valid text (and not onyl whitespace)
@ -117,7 +117,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.isValidText = function(string) me.isValidText = function(string)
{ {
return (string.length > 0 && $.trim(string) !== '') return (string.length > 0 && $.trim(string) !== '')
}; }
/** /**
* text range selection * text range selection
@ -143,7 +143,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
selection.removeAllRanges(); selection.removeAllRanges();
selection.addRange(range); selection.addRange(range);
} }
}; }
/** /**
* set text of a jQuery element (required for IE), * set text of a jQuery element (required for IE),
@ -165,7 +165,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
{ {
$element.text(text); $element.text(text);
} }
}; }
/** /**
* convert URLs to clickable links. * convert URLs to clickable links.
@ -195,7 +195,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
markup markup
) )
); );
}; }
/** /**
* minimal sprintf emulation for %s and %d formats * minimal sprintf emulation for %s and %d formats
@ -235,7 +235,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
return val; return val;
}); });
}; }
/** /**
* get value of cookie, if it was set, empty string otherwise * get value of cookie, if it was set, empty string otherwise
@ -261,7 +261,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
} }
return ''; return '';
}; }
/** /**
* get the current location (without search or hash part of the URL), * get the current location (without search or hash part of the URL),
@ -289,7 +289,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
return baseUri; return baseUri;
}; }
/** /**
* convert all applicable characters to HTML entities * convert all applicable characters to HTML entities
@ -305,7 +305,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
/[&<>"'`=\/]/g, function(s) { /[&<>"'`=\/]/g, function(s) {
return entityMap[s]; return entityMap[s];
}); });
}; }
return me; return me;
})(window, document); })(window, document);
@ -369,7 +369,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me._ = function() me._ = function()
{ {
return me.translate.apply(this, arguments); return me.translate.apply(this, arguments);
}; }
/** /**
* translate a string * translate a string
@ -467,7 +467,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
return output; return output;
}; }
/** /**
* per language functions to use to determine the plural form * per language functions to use to determine the plural form
@ -495,7 +495,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
default: default:
return (n !== 1 ? 1 : 0); return (n !== 1 ? 1 : 0);
} }
}; }
/** /**
* load translations into cache * load translations into cache
@ -539,7 +539,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
console.error('Language \'%s\' could not be loaded (%s: %s). Translation failed, fallback to English.', newLanguage, textStatus, errorMsg); console.error('Language \'%s\' could not be loaded (%s: %s). Translation failed, fallback to English.', newLanguage, textStatus, errorMsg);
language = 'en'; language = 'en';
}); });
}; }
return me; return me;
})(window, document); })(window, document);
@ -603,7 +603,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
return sjcl.encrypt(key, compress(message), options); return sjcl.encrypt(key, compress(message), options);
} }
return sjcl.encrypt(key + sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(password)), compress(message), options); return sjcl.encrypt(key + sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(password)), compress(message), options);
}; }
/** /**
* decrypt message with key, then decompress * decrypt message with key, then decompress
@ -629,7 +629,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
} }
return ''; return '';
}; }
/** /**
* checks whether the crypt tool is ready. * checks whether the crypt tool is ready.
@ -641,7 +641,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.isEntropyReady = function() me.isEntropyReady = function()
{ {
return sjcl.random.isReady(); return sjcl.random.isReady();
}; }
/** /**
* checks whether the crypt tool is ready. * checks whether the crypt tool is ready.
@ -653,7 +653,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.addEntropySeedListener = function(func) me.addEntropySeedListener = function(func)
{ {
sjcl.random.addEventListener('seeded', func); sjcl.random.addEventListener('seeded', func);
}; }
/** /**
* returns a random symmetric key * returns a random symmetric key
@ -665,7 +665,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getSymmetricKey = function(func) me.getSymmetricKey = function(func)
{ {
return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0); return sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0);
}; }
/** /**
* initialize crypt tool * initialize crypt tool
@ -682,7 +682,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// I18n._('Messages cannot be decrypted or encrypted.') // I18n._('Messages cannot be decrypted or encrypted.')
// ); // );
// } // }
}; }
return me; return me;
})(); })();
@ -690,11 +690,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
/** /**
* (Model) Data source (aka MVC) * (Model) Data source (aka MVC)
* *
* @param {object} window
* @param {object} document
* @class * @class
*/ */
var Model = (function (window, document) { var Model = (function () {
var me = {}; var me = {};
var $cipherData, var $cipherData,
@ -713,7 +711,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getExpirationDefault = function() me.getExpirationDefault = function()
{ {
return $('#pasteExpiration').val(); return $('#pasteExpiration').val();
}; }
/** /**
* returns the format set in the HTML * returns the format set in the HTML
@ -726,7 +724,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getFormatDefault = function() me.getFormatDefault = function()
{ {
return $('#pasteFormatter').val(); return $('#pasteFormatter').val();
}; }
/** /**
* check if cipher data was supplied * check if cipher data was supplied
@ -738,7 +736,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.hasCipherData = function() me.hasCipherData = function()
{ {
return (me.getCipherData().length > 0); return (me.getCipherData().length > 0);
}; }
/** /**
* returns the cipher data * returns the cipher data
@ -750,7 +748,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getCipherData = function() me.getCipherData = function()
{ {
return $cipherData.text(); return $cipherData.text();
}; }
/** /**
* get the pastes unique identifier from the URL, * get the pastes unique identifier from the URL,
@ -772,7 +770,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
return id; return id;
}; }
/** /**
* return the deciphering key stored in anchor part of the URL * return the deciphering key stored in anchor part of the URL
@ -798,11 +796,10 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
{ {
symmetricKey = symmetricKey.substring(0, ampersandPos); symmetricKey = symmetricKey.substring(0, ampersandPos);
} }
} }
return symmetricKey; return symmetricKey;
}; }
/** /**
* returns a jQuery copy of the HTML template * returns a jQuery copy of the HTML template
@ -820,6 +817,17 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
return $element.prop('id', name); return $element.prop('id', name);
} }
/**
* resets state, used for unit testing
*
* @name Model.reset
* @function
*/
me.reset = function()
{
$cipherData = $templates = id = symmetricKey = null;
}
/** /**
* init navigation manager * init navigation manager
@ -833,10 +841,10 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
{ {
$cipherData = $('#cipherdata'); $cipherData = $('#cipherdata');
$templates = $('#templates'); $templates = $('#templates');
}; }
return me; return me;
})(window, document); })();
/** /**
* Helper functions for user interface * Helper functions for user interface
@ -869,7 +877,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// redirect to home page // redirect to home page
window.location.href = currentLocation; window.location.href = currentLocation;
} }
}; }
/** /**
* reload the page * reload the page
@ -882,7 +890,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.reloadHome = function() me.reloadHome = function()
{ {
window.location.href = Helper.baseUri(); window.location.href = Helper.baseUri();
}; }
/** /**
* checks whether the element is currently visible in the viewport (so * checks whether the element is currently visible in the viewport (so
@ -903,7 +911,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
var viewportBottom = viewportTop + $(window).height(); var viewportBottom = viewportTop + $(window).height();
return (elementTop > viewportTop && elementTop < viewportBottom); return (elementTop > viewportTop && elementTop < viewportBottom);
}; }
/** /**
* scrolls to a specific element * scrolls to a specific element
@ -956,7 +964,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
next(); next();
}); });
}; }
/** /**
* initialize * initialize
@ -970,7 +978,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
$('.reloadlink').prop('href', Helper.baseUri()); $('.reloadlink').prop('href', Helper.baseUri());
$(window).on('popstate', historyChange); $(window).on('popstate', historyChange);
}; }
return me; return me;
})(window, document); })(window, document);
@ -1095,7 +1103,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// @TODO: implement autoclose // @TODO: implement autoclose
handleNotification(1, $statusMessage, message, icon); handleNotification(1, $statusMessage, message, icon);
}; }
/** /**
* display an error message * display an error message
@ -1120,7 +1128,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// @TODO: implement autoclose // @TODO: implement autoclose
handleNotification(3, $errorMessage, message, icon); handleNotification(3, $errorMessage, message, icon);
}; }
/** /**
* shows a loading message, optionally with a percentage * shows a loading message, optionally with a percentage
@ -1151,7 +1159,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// show loading status (cursor) // show loading status (cursor)
$('body').addClass('loading'); $('body').addClass('loading');
}; }
/** /**
* hides the loading message * hides the loading message
@ -1165,7 +1173,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// hide loading cursor // hide loading cursor
$('body').removeClass('loading'); $('body').removeClass('loading');
}; }
/** /**
* hides any status/error messages * hides any status/error messages
@ -1180,7 +1188,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// also possible: $('.statusmessage').addClass('hidden'); // also possible: $('.statusmessage').addClass('hidden');
$statusMessage.addClass('hidden'); $statusMessage.addClass('hidden');
$errorMessage.addClass('hidden'); $errorMessage.addClass('hidden');
}; }
/** /**
* set a custom handler, which gets all notifications. * set a custom handler, which gets all notifications.
@ -1203,7 +1211,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.setCustomHandler = function(newHandler) me.setCustomHandler = function(newHandler)
{ {
customHandler = newHandler; customHandler = newHandler;
}; }
/** /**
* init status manager * init status manager
@ -1234,7 +1242,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
if (Helper.isValidText(serverError)) { if (Helper.isValidText(serverError)) {
Alert.showError(); Alert.showError();
} }
}; }
return me; return me;
})(window, document); })(window, document);
@ -1296,7 +1304,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
*/ */
me.createPasteNotification = function(url, deleteUrl) me.createPasteNotification = function(url, deleteUrl)
{ {
$('#pastelink').find(':first').html( $('#pastelink').html(
I18n._( I18n._(
'Your paste is <a id="pasteurl" href="%s">%s</a> <span id="copyhint">(Hit [Ctrl]+[c] to copy)</span>', 'Your paste is <a id="pasteurl" href="%s">%s</a> <span id="copyhint">(Hit [Ctrl]+[c] to copy)</span>',
url, url url, url
@ -1314,7 +1322,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
$pasteSuccess.removeClass('hidden'); $pasteSuccess.removeClass('hidden');
// we pre-select the link so that the user only has to [Ctrl]+[c] the link // we pre-select the link so that the user only has to [Ctrl]+[c] the link
Helper.selectText($pasteUrl[0]); Helper.selectText($pasteUrl[0]);
}; }
/** /**
* shows the remaining time * shows the remaining time
@ -1354,7 +1362,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// in the end, display notification // in the end, display notification
$remainingTime.removeClass('hidden'); $remainingTime.removeClass('hidden');
}; }
/** /**
* hides the remaining time and successful upload notification * hides the remaining time and successful upload notification
@ -1366,7 +1374,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
{ {
$remainingTime.addClass('hidden'); $remainingTime.addClass('hidden');
$pasteSuccess.addClass('hidden'); $pasteSuccess.addClass('hidden');
}; }
/** /**
* init status manager * init status manager
@ -1385,7 +1393,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// bind elements // bind elements
$shortenButton.click(sendToShortener); $shortenButton.click(sendToShortener);
}; }
return me; return me;
})(window, document); })(window, document);
@ -1442,7 +1450,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
if (passwordCallback !== null) { if (passwordCallback !== null) {
passwordCallback(); passwordCallback();
} }
}; }
/** /**
* getthe cached password * getthe cached password
@ -1457,7 +1465,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getPassword = function() me.getPassword = function()
{ {
return password; return password;
}; }
/** /**
* setsthe callback called when password is entered * setsthe callback called when password is entered
@ -1469,7 +1477,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.setPasswordCallback = function(callback) me.setPasswordCallback = function(callback)
{ {
passwordCallback = callback; passwordCallback = callback;
}; }
/** /**
* submit a password in the modal dialog * submit a password in the modal dialog
@ -1516,7 +1524,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
}); });
// handle Model password submission // handle Model password submission
$passwordForm.submit(submitPasswordModal); $passwordForm.submit(submitPasswordModal);
}; }
return me; return me;
})(window, document); })(window, document);
@ -1651,7 +1659,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// clear content // clear content
$message.val(''); $message.val('');
}; }
/** /**
* shows the Editor * shows the Editor
@ -1663,7 +1671,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
{ {
$message.removeClass('hidden'); $message.removeClass('hidden');
$editorTabs.removeClass('hidden'); $editorTabs.removeClass('hidden');
}; }
/** /**
* hides the Editor * hides the Editor
@ -1675,7 +1683,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
{ {
$message.addClass('hidden'); $message.addClass('hidden');
$editorTabs.addClass('hidden'); $editorTabs.addClass('hidden');
}; }
/** /**
* focuses the message input * focuses the message input
@ -1686,7 +1694,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.focusInput = function() me.focusInput = function()
{ {
$message.focus(); $message.focus();
}; }
/** /**
* sets a new text * sets a new text
@ -1698,7 +1706,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.setText = function(newText) me.setText = function(newText)
{ {
$message.val(newText); $message.val(newText);
}; }
/** /**
* returns the current text * returns the current text
@ -1710,7 +1718,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getText = function() me.getText = function()
{ {
return $message.val() return $message.val()
}; }
/** /**
* init status manager * init status manager
@ -1732,7 +1740,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// (li) // (li)
$messageEdit = $('#messageedit').click(viewEditor).parent(); $messageEdit = $('#messageedit').click(viewEditor).parent();
$messagePreview = $('#messagepreview').click(viewPreview).parent(); $messagePreview = $('#messagepreview').click(viewPreview).parent();
}; }
return me; return me;
})(window, document); })(window, document);
@ -1860,7 +1868,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
format = newFormat; format = newFormat;
isChanged = true; isChanged = true;
}; }
/** /**
* returns the current format * returns the current format
@ -1872,7 +1880,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getFormat = function() me.getFormat = function()
{ {
return format; return format;
}; }
/** /**
* returns whether the current view is pretty printed * returns whether the current view is pretty printed
@ -1884,7 +1892,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.isPrettyPrinted = function() me.isPrettyPrinted = function()
{ {
return $prettyPrint.hasClass('prettyprinted'); return $prettyPrint.hasClass('prettyprinted');
}; }
/** /**
* sets the text to show * sets the text to show
@ -1899,7 +1907,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
text = newText; text = newText;
isChanged = true; isChanged = true;
} }
}; }
/** /**
* gets the current cached text * gets the current cached text
@ -1911,7 +1919,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getText = function(newText) me.getText = function(newText)
{ {
return text; return text;
}; }
/** /**
* show/update the parsed text (preview) * show/update the parsed text (preview)
@ -1930,7 +1938,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
showPaste(); showPaste();
isDisplayed = true; isDisplayed = true;
} }
}; }
/** /**
* hide parsed text (preview) * hide parsed text (preview)
@ -1949,7 +1957,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
$placeholder.addClass('hidden'); $placeholder.addClass('hidden');
isDisplayed = false; isDisplayed = false;
}; }
/** /**
* init status manager * init status manager
@ -1982,7 +1990,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// get default option from template/HTML or fall back to set value // get default option from template/HTML or fall back to set value
format = Model.getFormatDefault() || format; format = Model.getFormatDefault() || format;
}; }
return me; return me;
})(window, document); })(window, document);
@ -2032,7 +2040,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
attachmentChanged = true; attachmentChanged = true;
}; }
/** /**
* displays the attachment * displays the attachment
@ -2102,7 +2110,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.hasAttachment = function() me.hasAttachment = function()
{ {
return ($attachmentLink.prop('href') !== '') return ($attachmentLink.prop('href') !== '')
}; }
/** /**
* return the attachment * return the attachment
@ -2117,7 +2125,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
$attachmentLink.prop('href'), $attachmentLink.prop('href'),
$attachmentLink.prop('download') $attachmentLink.prop('download')
]; ];
}; }
/** /**
* moves the attachment link to another element * moves the attachment link to another element
@ -2136,7 +2144,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// update text // update text
I18n._($attachmentLink, label, $attachmentLink.attr('download')); I18n._($attachmentLink, label, $attachmentLink.attr('download'));
}; }
/** /**
* initiate * initiate
@ -2151,7 +2159,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
$attachment = $('#attachment'); $attachment = $('#attachment');
$attachmentLink = $('#attachment a'); $attachmentLink = $('#attachment a');
$attachmentPreview = $('#attachmentPreview'); $attachmentPreview = $('#attachmentPreview');
}; }
return me; return me;
})(window, document); })(window, document);
@ -2224,7 +2232,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
return $replyStatus; return $replyStatus;
}; }
/** /**
* open the comment entry when clicking the "Reply" button of a comment * open the comment entry when clicking the "Reply" button of a comment
@ -2313,7 +2321,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// finally append comment // finally append comment
$place.append($commentEntry); $place.append($commentEntry);
}; }
/** /**
* finishes the discussion area after last comment * finishes the discussion area after last comment
@ -2328,7 +2336,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// show discussions // show discussions
$discussion.removeClass('hidden'); $discussion.removeClass('hidden');
}; }
/** /**
* shows the discussion area * shows the discussion area
@ -2339,7 +2347,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.showDiscussion = function() me.showDiscussion = function()
{ {
$discussion.removeClass('hidden'); $discussion.removeClass('hidden');
}; }
/** /**
* removes the old discussion and prepares everything for creating a new * removes the old discussion and prepares everything for creating a new
@ -2355,7 +2363,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// (re-)init templates // (re-)init templates
initTemplates(); initTemplates();
}; }
/** /**
* returns the user put into the reply form * returns the user put into the reply form
@ -2370,7 +2378,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
$replyMessage.val(), $replyMessage.val(),
$replyNickname.val() $replyNickname.val()
]; ];
}; }
/** /**
* highlights a specific comment and scrolls to it if necessary * highlights a specific comment and scrolls to it if necessary
@ -2402,7 +2410,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
UiHelper.scrollTo($comment, 100, 'swing', highlightComment); UiHelper.scrollTo($comment, 100, 'swing', highlightComment);
}; }
/** /**
* returns the id of the parent comment the user is replying to * returns the id of the parent comment the user is replying to
@ -2414,7 +2422,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getReplyCommentId = function() me.getReplyCommentId = function()
{ {
return replyCommentId; return replyCommentId;
}; }
/** /**
* initiate * initiate
@ -2432,7 +2440,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
$commentContainer = $('#commentcontainer'); $commentContainer = $('#commentcontainer');
$discussion = $('#discussion'); $discussion = $('#discussion');
}; }
return me; return me;
})(window, document); })(window, document);
@ -2643,7 +2651,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.loadDefaults = function() me.loadDefaults = function()
{ {
// @TODO // @TODO
}; }
/** /**
* Shows all elements belonging to viwing an existing pastes * Shows all elements belonging to viwing an existing pastes
@ -2663,7 +2671,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
$rawTextButton.removeClass('hidden'); $rawTextButton.removeClass('hidden');
viewButtonsDisplayed = true; viewButtonsDisplayed = true;
}; }
/** /**
* Hides all elements belonging to existing pastes * Hides all elements belonging to existing pastes
@ -2683,7 +2691,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
$rawTextButton.addClass('hidden'); $rawTextButton.addClass('hidden');
viewButtonsDisplayed = false; viewButtonsDisplayed = false;
}; }
/** /**
* Hides all elements belonging to existing pastes * Hides all elements belonging to existing pastes
@ -2695,7 +2703,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
{ {
me.hideViewButtons(); me.hideViewButtons();
me.hideCreateButtons(); me.hideCreateButtons();
}; }
/** /**
* shows all elements needed when creating a new paste * shows all elements needed when creating a new paste
@ -2720,7 +2728,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
$attach.removeClass('hidden'); $attach.removeClass('hidden');
createButtonsDisplayed = true; createButtonsDisplayed = true;
}; }
/** /**
* shows all elements needed when creating a new paste * shows all elements needed when creating a new paste
@ -2745,7 +2753,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
$attach.addClass('hidden'); $attach.addClass('hidden');
createButtonsDisplayed = false; createButtonsDisplayed = false;
}; }
/** /**
* only shows the "new paste" button * only shows the "new paste" button
@ -2756,7 +2764,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.showNewPasteButton = function() me.showNewPasteButton = function()
{ {
$newButton.removeClass('hidden'); $newButton.removeClass('hidden');
}; }
/** /**
* only hides the clone button * only hides the clone button
@ -2767,7 +2775,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.hideCloneButton = function() me.hideCloneButton = function()
{ {
$cloneButton.addClass('hidden'); $cloneButton.addClass('hidden');
}; }
/** /**
* only hides the raw text button * only hides the raw text button
@ -2778,7 +2786,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.hideRawButton = function() me.hideRawButton = function()
{ {
$rawTextButton.addClass('hidden'); $rawTextButton.addClass('hidden');
}; }
/** /**
* hides the file selector in attachment * hides the file selector in attachment
@ -2789,7 +2797,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.hideFileSelector = function() me.hideFileSelector = function()
{ {
$fileWrap.addClass('hidden'); $fileWrap.addClass('hidden');
}; }
/** /**
@ -2801,7 +2809,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.showCustomAttachment = function() me.showCustomAttachment = function()
{ {
$customAttachment.removeClass('hidden'); $customAttachment.removeClass('hidden');
}; }
/** /**
* collapses the navigation bar if nedded * collapses the navigation bar if nedded
@ -2818,7 +2826,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// if so, toggle it // if so, toggle it
$bar.click(); $bar.click();
} }
}; }
/** /**
* returns the currently set expiration time * returns the currently set expiration time
@ -2830,7 +2838,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getExpiration = function() me.getExpiration = function()
{ {
return pasteExpiration; return pasteExpiration;
}; }
/** /**
* returns the currently selected file(s) * returns the currently selected file(s)
@ -2853,7 +2861,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
return $file[0].files; return $file[0].files;
}; }
/** /**
* returns the state of the burn after reading checkbox * returns the state of the burn after reading checkbox
@ -2865,7 +2873,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getBurnAfterReading = function() me.getBurnAfterReading = function()
{ {
return $burnAfterReading.is(':checked'); return $burnAfterReading.is(':checked');
}; }
/** /**
* returns the state of the discussion checkbox * returns the state of the discussion checkbox
@ -2877,7 +2885,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getOpenDiscussion = function() me.getOpenDiscussion = function()
{ {
return $openDiscussion.is(':checked'); return $openDiscussion.is(':checked');
}; }
/** /**
* returns the entered password * returns the entered password
@ -2889,7 +2897,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getPassword = function() me.getPassword = function()
{ {
return $passwordInput.val(); return $passwordInput.val();
}; }
/** /**
* returns the element where custom attachments can be placed * returns the element where custom attachments can be placed
@ -2903,7 +2911,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.getCustomAttachment = function() me.getCustomAttachment = function()
{ {
return $customAttachment; return $customAttachment;
}; }
/** /**
* init navigation manager * init navigation manager
@ -2958,7 +2966,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
pasteExpiration = Model.getExpirationDefault() || pasteExpiration; pasteExpiration = Model.getExpirationDefault() || pasteExpiration;
me.loadDefaults(); me.loadDefaults();
}; }
return me; return me;
})(window, document); })(window, document);
@ -3094,7 +3102,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
console.error(textStatus, errorThrown); console.error(textStatus, errorThrown);
fail(3, jqXHR); fail(3, jqXHR);
}); });
}; }
/** /**
* set success function * set success function
@ -3106,7 +3114,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.setUrl = function(newUrl) me.setUrl = function(newUrl)
{ {
url = newUrl; url = newUrl;
}; }
/** /**
* sets the password to use (first value) and optionally also the * sets the password to use (first value) and optionally also the
@ -3126,7 +3134,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
if (typeof newKey !== 'undefined') { if (typeof newKey !== 'undefined') {
symmetricKey = newKey; symmetricKey = newKey;
} }
}; }
/** /**
* set success function * set success function
@ -3138,7 +3146,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.setSuccess = function(func) me.setSuccess = function(func)
{ {
successFunc = func; successFunc = func;
}; }
/** /**
* set failure function * set failure function
@ -3150,7 +3158,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.setFailure = function(func) me.setFailure = function(func)
{ {
failureFunc = func; failureFunc = func;
}; }
/** /**
* prepares a new upload * prepares a new upload
@ -3178,7 +3186,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
failureFunc = null; failureFunc = null;
url = Helper.baseUri(); url = Helper.baseUri();
data = {}; data = {};
}; }
/** /**
* encrypts and sets the data * encrypts and sets the data
@ -3192,7 +3200,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
{ {
checkCryptParameters(); checkCryptParameters();
data[index] = CryptTool.cipher(symmetricKey, password, element); data[index] = CryptTool.cipher(symmetricKey, password, element);
}; }
/** /**
* set the additional metadata to send unencrypted * set the additional metadata to send unencrypted
@ -3205,7 +3213,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.setUnencryptedData = function(index, element) me.setUnencryptedData = function(index, element)
{ {
data[index] = element; data[index] = element;
}; }
/** /**
* set the additional metadata to send unencrypted passed at once * set the additional metadata to send unencrypted passed at once
@ -3217,7 +3225,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.setUnencryptedBulkData = function(newData) me.setUnencryptedBulkData = function(newData)
{ {
$.extend(data, newData); $.extend(data, newData);
}; }
/** /**
* Helper, which parses shows a general error message based on the result of the Uploader * Helper, which parses shows a general error message based on the result of the Uploader
@ -3258,7 +3266,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.init = function() me.init = function()
{ {
// nothing yet // nothing yet
}; }
return me; return me;
})(); })();
@ -3381,7 +3389,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// run callback // run callback
return callback(); return callback();
}; }
// actually read first file // actually read first file
reader.readAsDataURL(file); reader.readAsDataURL(file);
@ -3413,8 +3421,10 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
TopNav.hideAllButtons(); TopNav.hideAllButtons();
Alert.showLoading('Sending comment…', 0, 'cloud-upload'); Alert.showLoading('Sending comment…', 0, 'cloud-upload');
// get data // get data, note that "var [x, y] = " structures aren't supported in all JS environments
var [plainText, nickname] = DiscussionViewer.getReplyData(), var replyData = DiscussionViewer.getReplyData(),
plainText = replyData[0],
nickname = replyData[1],
parentid = DiscussionViewer.getReplyCommentId(); parentid = DiscussionViewer.getReplyCommentId();
// do not send if there is no data // do not send if there is no data
@ -3470,7 +3480,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
} }
Uploader.run(); Uploader.run();
}; }
/** /**
* sends a new paste to server * sends a new paste to server
@ -3548,7 +3558,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
Uploader.run(); Uploader.run();
} }
); );
}; }
/** /**
* initialize * initialize
@ -3559,7 +3569,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.init = function() me.init = function()
{ {
// nothing yet // nothing yet
}; }
return me; return me;
})(); })();
@ -3795,7 +3805,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
Alert.hideLoading(); Alert.hideLoading();
TopNav.showViewButtons(); TopNav.showViewButtons();
}; }
/** /**
* initialize * initialize
@ -3806,7 +3816,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.init = function() me.init = function()
{ {
// nothing yet // nothing yet
}; }
return me; return me;
})(); })();
@ -3831,7 +3841,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
{ {
PasteStatus.hideMessages(); PasteStatus.hideMessages();
Alert.hideMessages(); Alert.hideMessages();
}; }
/** /**
* creates a new paste * creates a new paste
@ -3855,7 +3865,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
TopNav.loadDefaults(); TopNav.loadDefaults();
TopNav.showCreateButtons(); TopNav.showCreateButtons();
Alert.hideLoading(); Alert.hideLoading();
}; }
/** /**
* shows the loaded paste * shows the loaded paste
@ -3882,7 +3892,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// show proper elements on screen // show proper elements on screen
PasteDecrypter.run(); PasteDecrypter.run();
return; return;
}; }
/** /**
* refreshes the loaded paste to show potential new data * refreshes the loaded paste to show potential new data
@ -3916,7 +3926,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
callback(); callback();
}) })
Uploader.run(); Uploader.run();
}; }
/** /**
* clone the current paste * clone the current paste
@ -3964,7 +3974,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
Alert.hideLoading(); Alert.hideLoading();
TopNav.showCreateButtons(); TopNav.showCreateButtons();
}; }
/** /**
* removes a saved paste * removes a saved paste
@ -3985,7 +3995,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
Controller.showError(I18n._('Could not delete the paste, it was not stored in burn after reading mode.')); Controller.showError(I18n._('Could not delete the paste, it was not stored in burn after reading mode.'));
}) })
Uploader.run(); Uploader.run();
}; }
/** /**
* application start * application start
@ -4022,7 +4032,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// otherwise create a new paste // otherwise create a new paste
me.newPaste(); me.newPaste();
}; }
return me; return me;
})(window, document); })(window, document);

@ -20,7 +20,7 @@ global.RawDeflate = require('./rawdeflate-0.5');
require('./rawinflate-0.3'); require('./rawinflate-0.3');
require('./privatebin'); require('./privatebin');
describe('helper', function () { describe('Helper', function () {
describe('secondsToHuman', function () { describe('secondsToHuman', function () {
after(function () { after(function () {
cleanup(); cleanup();
@ -66,7 +66,7 @@ describe('helper', function () {
}); });
}); });
describe('scriptLocation', function () { describe('baseUri', function () {
jsc.property( jsc.property(
'returns the URL without query & fragment', 'returns the URL without query & fragment',
jsc.nearray(jsc.elements(a2zString)), jsc.nearray(jsc.elements(a2zString)),
@ -76,19 +76,36 @@ describe('helper', function () {
function (schema, address, query, fragment) { function (schema, address, query, fragment) {
var expected = schema.join('') + '://' + address.join('') + '/', var expected = schema.join('') + '://' + address.join('') + '/',
clean = jsdom('', {url: expected + '?' + query.join('') + '#' + fragment}), clean = jsdom('', {url: expected + '?' + query.join('') + '#' + fragment}),
result = $.PrivateBin.Helper.scriptLocation(); result = $.PrivateBin.Helper.baseUri();
clean(); clean();
return expected === result; return expected === result;
} }
); );
}); });
describe('pasteId', function () { describe('htmlEntities', function () {
after(function () {
cleanup();
});
jsc.property(
'removes all HTML entities from any given string',
'string',
function (string) {
var result = $.PrivateBin.Helper.htmlEntities(string);
return !(/[<>"'`=\/]/.test(result)) && !(string.indexOf('&') > -1 && !(/&amp;/.test(result)));
}
);
});
});
describe('Model', function () {
describe('getPasteId', function () {
jsc.property( jsc.property(
'returns the query string without separator, if any', 'returns the query string without separator, if any',
jsc.nearray(jsc.elements(a2zString)), jsc.nearray(jsc.elements(a2zString)),
jsc.nearray(jsc.elements(a2zString)), jsc.nearray(jsc.elements(a2zString)),
jsc.array(jsc.elements(queryString)), jsc.nearray(jsc.elements(queryString)),
'string', 'string',
function (schema, address, query, fragment) { function (schema, address, query, fragment) {
var queryString = query.join(''), var queryString = query.join(''),
@ -96,27 +113,29 @@ describe('helper', function () {
url: schema.join('') + '://' + address.join('') + url: schema.join('') + '://' + address.join('') +
'/?' + queryString + '#' + fragment '/?' + queryString + '#' + fragment
}), }),
result = $.PrivateBin.Helper.pasteId(); result = $.PrivateBin.Model.getPasteId();
$.PrivateBin.Model.reset();
clean(); clean();
return queryString === result; return queryString === result;
} }
); );
}); });
describe('pageKey', function () { describe('getPasteKey', function () {
jsc.property( jsc.property(
'returns the fragment of the URL', 'returns the fragment of the URL',
jsc.nearray(jsc.elements(a2zString)), jsc.nearray(jsc.elements(a2zString)),
jsc.nearray(jsc.elements(a2zString)), jsc.nearray(jsc.elements(a2zString)),
jsc.array(jsc.elements(queryString)), jsc.array(jsc.elements(queryString)),
jsc.array(jsc.elements(base64String)), jsc.nearray(jsc.elements(base64String)),
function (schema, address, query, fragment) { function (schema, address, query, fragment) {
var fragmentString = fragment.join(''), var fragmentString = fragment.join(''),
clean = jsdom('', { clean = jsdom('', {
url: schema.join('') + '://' + address.join('') + url: schema.join('') + '://' + address.join('') +
'/?' + query.join('') + '#' + fragmentString '/?' + query.join('') + '#' + fragmentString
}), }),
result = $.PrivateBin.Modal.getPasteKey(); result = $.PrivateBin.Model.getPasteKey();
$.PrivateBin.Model.reset();
clean(); clean();
return fragmentString === result; return fragmentString === result;
} }
@ -126,7 +145,7 @@ describe('helper', function () {
jsc.nearray(jsc.elements(a2zString)), jsc.nearray(jsc.elements(a2zString)),
jsc.nearray(jsc.elements(a2zString)), jsc.nearray(jsc.elements(a2zString)),
jsc.array(jsc.elements(queryString)), jsc.array(jsc.elements(queryString)),
jsc.array(jsc.elements(base64String)), jsc.nearray(jsc.elements(base64String)),
jsc.array(jsc.elements(queryString)), jsc.array(jsc.elements(queryString)),
function (schema, address, query, fragment, trail) { function (schema, address, query, fragment, trail) {
var fragmentString = fragment.join(''), var fragmentString = fragment.join(''),
@ -134,25 +153,11 @@ describe('helper', function () {
url: schema.join('') + '://' + address.join('') + '/?' + url: schema.join('') + '://' + address.join('') + '/?' +
query.join('') + '#' + fragmentString + '&' + trail.join('') query.join('') + '#' + fragmentString + '&' + trail.join('')
}), }),
result = $.PrivateBin.Modal.getPasteKey(); result = $.PrivateBin.Model.getPasteKey();
$.PrivateBin.Model.reset();
clean(); clean();
return fragmentString === result; return fragmentString === result;
} }
); );
}); });
describe('htmlEntities', function () {
after(function () {
cleanup();
});
jsc.property(
'removes all HTML entities from any given string',
'string',
function (string) {
var result = $.PrivateBin.Helper.htmlEntities(string);
return !(/[<>"'`=\/]/.test(result)) && !(string.indexOf('&') > -1 && !(/&amp;/.test(result)));
}
);
});
}); });

@ -69,7 +69,7 @@ if ($MARKDOWN):
<?php <?php
endif; endif;
?> ?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-vYYJYraxQNOf41XtehLBU2JbIQ2Uffe+n8TjHyWkpqoZdZX4aL5zyABrUNvRUP02+AxoRsmNJkpvIbmeQqcIXg==" crossorigin="anonymous"></script> <script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-iGFkRUeioseXBM4QLP9xFBK9RaGHPqTnl4NgVhjw0wm0xURcjpL5HE9WP+XJRY0UF3VbIoiuyFXSp0JpxSbc+A==" crossorigin="anonymous"></script>
<!--[if lt IE 10]> <!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style> <style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]--> <![endif]-->
@ -122,7 +122,7 @@ endif;
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li id="loadingindicator" class="navbar-text hidden"> <li id="loadingindicator" class="navbar-text hidden">
<span class="glyphicon glyphicon-time" aria-hidden="true"></span> <span class="glyphicon glyphicon-time" aria-hidden="true"></span>
<span><?php echo I18n::_('Loading…'), PHP_EOL; ?></span> <?php echo I18n::_('Loading…'), PHP_EOL; ?>
</li> </li>
<li> <li>
<?php <?php
@ -369,23 +369,23 @@ endif;
</ul> </ul>
</div> </div>
<?php <?php
if ($isCpct): if ($isCpct):
?></div><?php ?></div><?php
endif; endif;
?></nav> ?></nav>
<main> <main>
<section class="container"> <section class="container">
<?php <?php
if (strlen($NOTICE)): if (strlen($NOTICE)):
?> ?>
<div role="alert" class="alert alert-info"> <div role="alert" class="alert alert-info">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span><span><?php echo htmlspecialchars($NOTICE), PHP_EOL; ?></span> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span><?php echo htmlspecialchars($NOTICE), PHP_EOL; ?>
</div> </div>
<?php <?php
endif; endif;
?> ?>
<div id="remainingtime" role="alert" class="hidden alert alert-info"> <div id="remainingtime" role="alert" class="hidden alert alert-info">
<span class="glyphicon glyphicon-fire" aria-hidden="true"></span><span></span> <span class="glyphicon glyphicon-fire" aria-hidden="true"></span>
</div> </div>
<?php <?php
if ($FILEUPLOAD): if ($FILEUPLOAD):
@ -398,9 +398,9 @@ endif;
?> ?>
<div id="status" role="alert" class="statusmessage alert alert-info <?php echo empty($STATUS) ? 'hidden' : '' ?>"> <div id="status" role="alert" class="statusmessage alert alert-info <?php echo empty($STATUS) ? 'hidden' : '' ?>">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
<span><?php echo htmlspecialchars($STATUS); ?></span> <?php echo htmlspecialchars($STATUS); ?>
</div> </div>
<div id="errormessage" role="alert" class="statusmessage <?php echo empty($ERROR) ? 'hidden' : '' ?> alert alert-danger"><span class="glyphicon glyphicon-alert" aria-hidden="true"></span><span><?php echo htmlspecialchars($ERROR); ?></span></div> <div id="errormessage" role="alert" class="statusmessage <?php echo empty($ERROR) ? 'hidden' : '' ?> alert alert-danger"><span class="glyphicon glyphicon-alert" aria-hidden="true"></span><?php echo htmlspecialchars($ERROR); ?></div>
<noscript><div id="noscript" role="alert" class="nonworking alert alert-<?php echo $isDark ? 'error' : 'warning'; ?>"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span><?php echo I18n::_('JavaScript is required for %s to work.<br />Sorry for the inconvenience.', I18n::_($NAME)); ?></div></noscript> <noscript><div id="noscript" role="alert" class="nonworking alert alert-<?php echo $isDark ? 'error' : 'warning'; ?>"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span><?php echo I18n::_('JavaScript is required for %s to work.<br />Sorry for the inconvenience.', I18n::_($NAME)); ?></div></noscript>
<div id="oldienotice" role="alert" class="hidden nonworking alert alert-danger"><span class="glyphicon glyphicon-alert" aria-hidden="true"></span><?php echo I18n::_('%s requires a modern browser to work.', I18n::_($NAME)); ?></div> <div id="oldienotice" role="alert" class="hidden nonworking alert alert-danger"><span class="glyphicon glyphicon-alert" aria-hidden="true"></span><?php echo I18n::_('%s requires a modern browser to work.', I18n::_($NAME)); ?></div>
<div id="ienotice" role="alert" class="hidden alert alert-<?php echo $isDark ? 'error' : 'warning'; ?>"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span><?php echo I18n::_('Still using Internet Explorer? Do yourself a favor, switch to a modern browser:'), PHP_EOL; ?> <div id="ienotice" role="alert" class="hidden alert alert-<?php echo $isDark ? 'error' : 'warning'; ?>"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span><?php echo I18n::_('Still using Internet Explorer? Do yourself a favor, switch to a modern browser:'), PHP_EOL; ?>
@ -413,7 +413,6 @@ endif;
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span> <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
<div id="deletelink"></div> <div id="deletelink"></div>
<div id="pastelink"> <div id="pastelink">
<span></span>
<?php <?php
if (strlen($URLSHORTENER)): if (strlen($URLSHORTENER)):
?> ?>
@ -449,7 +448,7 @@ endif;
</section> </section>
<section class="container"> <section class="container">
<div id="noscript" role="alert" class="nonworking alert alert-info noscript-hide"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"> <div id="noscript" role="alert" class="nonworking alert alert-info noscript-hide"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true">
<span> <?php echo I18n::_('Loading…'); ?></span><br> <?php echo I18n::_('Loading…'); ?><br />
<span class="small"><?php echo I18n::_('In case this message never disappears please have a look at <a href="https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away">this FAQ for information to troubleshoot</a>.'); ?></span> <span class="small"><?php echo I18n::_('In case this message never disappears please have a look at <a href="https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away">this FAQ for information to troubleshoot</a>.'); ?></span>
</div> </div>
</section> </section>
@ -465,12 +464,18 @@ endif;
</main> </main>
<div id="serverdata" class="hidden" aria-hidden="true"> <div id="serverdata" class="hidden" aria-hidden="true">
<div id="cipherdata"><?php echo htmlspecialchars($CIPHERDATA, ENT_NOQUOTES); ?></div> <div id="cipherdata"><?php echo htmlspecialchars($CIPHERDATA, ENT_NOQUOTES); ?></div>
<?php
if ($DISCUSSION):
?>
<div id="templates"> <div id="templates">
<!-- @TODO: when I intend/structure this corrrectly Firefox adds whitespaces everywhere which completly destroy the layout. (same possible when you remove the template data below and show this area in the browser) --> <!-- @TODO: when I intend/structure this corrrectly Firefox adds whitespaces everywhere which completly destroy the layout. (same possible when you remove the template data below and show this area in the browser) -->
<article id="commenttemplate" class="comment"><div class="commentmeta"><span class="nickname">name</span><span class="commentdate">0000-00-00</span></div><div class="commentdata">c</div><button class="btn btn-default btn-sm"><?php echo I18n::_('Reply'); ?></button></article> <article id="commenttemplate" class="comment"><div class="commentmeta"><span class="nickname">name</span><span class="commentdate">0000-00-00</span></div><div class="commentdata">c</div><button class="btn btn-default btn-sm"><?php echo I18n::_('Reply'); ?></button></article>
<div id="commenttailtemplate" class="comment"><button class="btn btn-default btn-sm"><?php echo I18n::_('Add comment'); ?></button></div> <div id="commenttailtemplate" class="comment"><button class="btn btn-default btn-sm"><?php echo I18n::_('Add comment'); ?></button></div>
<div id="replytemplate" class="reply hidden"><input type="text" id="nickname" class="form-control" title="<?php echo I18n::_('Optional nickname…'); ?>" placeholder="<?php echo I18n::_('Optional nickname…'); ?>" /><textarea id="replymessage" class="replymessage form-control" cols="80" rows="7"></textarea><br /><div id="replystatus" role="alert" class="statusmessage hidden alert"><span class="glyphicon" aria-hidden="true"></span><span></span></div><button id="replybutton" class="btn btn-default btn-sm"><?php echo I18n::_('Post comment'); ?></button></div> <div id="replytemplate" class="reply hidden"><input type="text" id="nickname" class="form-control" title="<?php echo I18n::_('Optional nickname…'); ?>" placeholder="<?php echo I18n::_('Optional nickname…'); ?>" /><textarea id="replymessage" class="replymessage form-control" cols="80" rows="7"></textarea><br /><div id="replystatus" role="alert" class="statusmessage hidden alert"><span class="glyphicon" aria-hidden="true"></span><span></span></div><button id="replybutton" class="btn btn-default btn-sm"><?php echo I18n::_('Post comment'); ?></button></div>
</div> </div>
<?php
endif;
?>
</div> </div>
</body> </body>
</html> </html>

@ -47,7 +47,7 @@ if ($MARKDOWN):
<?php <?php
endif; endif;
?> ?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-vYYJYraxQNOf41XtehLBU2JbIQ2Uffe+n8TjHyWkpqoZdZX4aL5zyABrUNvRUP02+AxoRsmNJkpvIbmeQqcIXg==" crossorigin="anonymous"></script> <script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-iGFkRUeioseXBM4QLP9xFBK9RaGHPqTnl4NgVhjw0wm0xURcjpL5HE9WP+XJRY0UF3VbIoiuyFXSp0JpxSbc+A==" crossorigin="anonymous"></script>
<!--[if lt IE 10]> <!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style> <style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]--> <![endif]-->
@ -125,7 +125,7 @@ endif;
<?php <?php
if ($DISCUSSION): if ($DISCUSSION):
?> ?>
<div id="opendisc" class="button hidden"> <div id="opendiscussionoption" class="button hidden">
<input type="checkbox" id="opendiscussion" name="opendiscussion"<?php <input type="checkbox" id="opendiscussion" name="opendiscussion"<?php
if ($OPENDISCUSSION): if ($OPENDISCUSSION):
?> checked="checked"<?php ?> checked="checked"<?php

@ -739,10 +739,10 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
new PrivateBin; new PrivateBin;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertContains( $this->assertRegExp(
'<div id="cipherdata" class="hidden">' . '#<div id="cipherdata"[^>]*>' .
htmlspecialchars(Helper::getPasteAsJson(), ENT_NOQUOTES) . preg_quote(htmlspecialchars(Helper::getPasteAsJson(), ENT_NOQUOTES)) .
'</div>', '</div>#',
$content, $content,
'outputs data correctly' 'outputs data correctly'
); );
@ -818,10 +818,10 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
unset($burnPaste['meta']['salt']); unset($burnPaste['meta']['salt']);
$this->assertContains( $this->assertRegExp(
'<div id="cipherdata" class="hidden">' . '#<div id="cipherdata"[^>]*>' .
htmlspecialchars(Helper::getPasteAsJson($burnPaste['meta']), ENT_NOQUOTES) . preg_quote(htmlspecialchars(Helper::getPasteAsJson($burnPaste['meta']), ENT_NOQUOTES)) .
'</div>', '</div>#',
$content, $content,
'outputs data correctly' 'outputs data correctly'
); );
@ -889,10 +889,10 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$meta['formatter'] = 'syntaxhighlighting'; $meta['formatter'] = 'syntaxhighlighting';
$this->assertContains( $this->assertRegExp(
'<div id="cipherdata" class="hidden">' . '#<div id="cipherdata"[^>]*>' .
htmlspecialchars(Helper::getPasteAsJson($meta), ENT_NOQUOTES) . preg_quote(htmlspecialchars(Helper::getPasteAsJson($meta), ENT_NOQUOTES)) .
'</div>', '</div>#',
$content, $content,
'outputs data correctly' 'outputs data correctly'
); );
@ -914,10 +914,10 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
ob_end_clean(); ob_end_clean();
$oldPaste['meta']['formatter'] = 'plaintext'; $oldPaste['meta']['formatter'] = 'plaintext';
unset($oldPaste['meta']['salt']); unset($oldPaste['meta']['salt']);
$this->assertContains( $this->assertRegExp(
'<div id="cipherdata" class="hidden">' . '#<div id="cipherdata"[^>]*>' .
htmlspecialchars(Helper::getPasteAsJson($oldPaste['meta']), ENT_NOQUOTES) . preg_quote(htmlspecialchars(Helper::getPasteAsJson($oldPaste['meta']), ENT_NOQUOTES)) .
'</div>', '</div>#',
$content, $content,
'outputs data correctly' 'outputs data correctly'
); );

@ -96,10 +96,10 @@ class ViewTest extends PHPUnit_Framework_TestCase
public function testTemplateRendersCorrectly() public function testTemplateRendersCorrectly()
{ {
foreach ($this->_content as $template => $content) { foreach ($this->_content as $template => $content) {
$this->assertContains( $this->assertRegExp(
'<div id="cipherdata" class="hidden">' . '#<div[^>]+id="cipherdata"[^>]*>' .
htmlspecialchars(Helper::getPaste()['data'], ENT_NOQUOTES) . preg_quote(htmlspecialchars(Helper::getPaste()['data'], ENT_NOQUOTES)) .
'</div>', '</div>#',
$content, $content,
$template . ': outputs data correctly' $template . ': outputs data correctly'
); );
@ -119,7 +119,7 @@ class ViewTest extends PHPUnit_Framework_TestCase
$template . ': checked discussion if configured' $template . ': checked discussion if configured'
); );
$this->assertRegExp( $this->assertRegExp(
'#<[^>]+id="opendisc"[^>]*>#', '#<[^>]+id="opendiscussionoption"[^>]*>#',
$content, $content,
$template . ': discussions available if configured' $template . ': discussions available if configured'
); );

Loading…
Cancel
Save