Skip to content

Commit

Permalink
[SECURITY] Fixes security issues #4526, #4523 und #4522 reported by C…
Browse files Browse the repository at this point in the history
…odeQL (kitodo#1041)

Co-authored-by: Sebastian Meyer <[email protected]>
  • Loading branch information
frank-ulrich-weber and sebastian-meyer authored Oct 4, 2023
1 parent c7c1368 commit 2dfbef8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dlfViewerImageManipulationControl = function(options) {
* @type {Element}
* @private
*/
this.toolContainerEl_ = dlfUtils.exists(options.toolContainer) ? options.toolContainer : $(this.dic['parentContainer'])[0];
this.toolContainerEl_ = dlfUtils.exists(options.toolContainer) ? options.toolContainer : $.find(this.dic['parentContainer'])[0];

//
// Append open/close behavior to toolbox
Expand Down
3 changes: 1 addition & 2 deletions Resources/Public/JavaScript/PageView/PageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,7 @@ dlfViewer.prototype.displayHighlightWord = function(highlightWords = null) {

// exctract highlighWords from URL
if (this.highlightWords === null) {
var urlParams = dlfUtils.getUrlParams();
this.highlightWords = urlParams['tx_dlf[highlight_word]'];
this.highlightWords = dlfUtils.getUrlParam('tx_dlf[highlight_word]');
}

if (!dlfUtils.exists(this.highlightLayer)) {
Expand Down
13 changes: 8 additions & 5 deletions Resources/Public/JavaScript/PageView/SearchInDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ function getCurrentQueryParams(baseUrl) {
function getNavigationButtons(start, numFound) {
var buttons = "";

if (start > 0) {
buttons += '<input type="button" id="tx-dlf-search-in-document-button-previous" class="button-previous" onclick="previousResultPage();" value="' + $('#tx-dlf-search-in-document-label-previous').text() + '" />';
if(start > 0) {
buttons += '<input type="button" id="tx-dlf-search-in-document-button-previous" class="button-previous" onclick="previousResultPage();" />';
}

if (numFound > (start + 20)) {
buttons += '<input type="button" id="tx-dlf-search-in-document-button-next" class="button-next" onclick="nextResultPage();" value="' + $('#tx-dlf-search-in-document-label-next').text() + '" />';
if(numFound > (start + 20)) {
buttons += '<input type="button" id="tx-dlf-search-in-document-button-next" class="button-next" onclick="nextResultPage();" />';
}
return buttons;
}
Expand Down Expand Up @@ -265,11 +265,14 @@ $(document).ready(function() {

addImageHighlight(data);
} else {
resultList += '<li class="noresult">' + $('#tx-dlf-search-in-document-label-noresult').text() + '</li>';
resultList += '<li class="noresult"></li>';
}
resultList += '</ul>';
resultList += getNavigationButtons(start, data['numFound']);
$('#tx-dlf-search-in-document-results').html(resultList);
$('.noresult').text($('#tx-dlf-search-in-document-label-noresult').text());
$('.button-previous').attr('value', $('#tx-dlf-search-in-document-label-previous').text());
$('.button-next').attr('value', $('#tx-dlf-search-in-document-label-next').text());
},
"json"
)
Expand Down
17 changes: 5 additions & 12 deletions Resources/Public/JavaScript/PageView/Utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,21 +507,14 @@ dlfUtils.getCookie = function (name) {

/**
* Returns url parameters
* @returns {Object|undefined}
* @returns {string|null}
*/
dlfUtils.getUrlParams = function () {
dlfUtils.getUrlParam = function (param) {
if (Object.prototype.hasOwnProperty.call(location, 'search')) {
var search = decodeURIComponent(location.search).slice(1).split('&'),
params = {};

search.forEach(function (item) {
var s = item.split('=');
params[s[0]] = s[1];
});

return params;
const urlParams = new URLSearchParams(location.search);
return urlParams.get(param);
}
return undefined;
return null;
};

/**
Expand Down

0 comments on commit 2dfbef8

Please sign in to comment.