Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request #155 from nextcloud/do-set-albumpath-to-empty-if-e…
Browse files Browse the repository at this point in the history
…rror-is-thrown

Do set albumpath to an empty value if an error is thrown
  • Loading branch information
LukasReschke authored Sep 14, 2016
2 parents 1a1e8eb + ef4bd34 commit e4d4319
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions js/galleryview.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,34 @@
this.showLoading();
},

/**
* @param {string} path
* @returns {boolean}
*/
_isValidPath: function(path) {
var sections = path.split('/');
for (var i = 0; i < sections.length; i++) {
if (sections[i] === '..') {
return false;
}
}

return path.toLowerCase().indexOf(decodeURI('%0a')) === -1 &&
path.toLowerCase().indexOf(decodeURI('%00')) === -1;
},

/**
* Populates the view if there are images or albums to show
*
* @param {string} albumPath
* @param {string|undefined} errorMessage
*/
init: function (albumPath, errorMessage) {
// Set path to an empty value if not a valid one
if(!this._isValidPath(albumPath)) {
albumPath = '';
}

// Only do it when the app is initialised
if (this.requestId === -1) {
this._initButtons();
Expand Down

0 comments on commit e4d4319

Please sign in to comment.