Skip to content

Commit

Permalink
Merge pull request #542 from themeum/harun
Browse files Browse the repository at this point in the history
Security Fix - XSS on several page where course list bind.
  • Loading branch information
harunollyo authored Aug 28, 2023
2 parents 19d0f7b + d156d6f commit beaabf1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion assets/react/front/_select_dd_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ window.selectSearchField = (selectElement) => {
Array.from(options).forEach((item) => {
optionsList += `
<div class="tutor-form-select-option">
<span tutor-dropdown-item data-key="${item.value}" class="tutor-nowrap-ellipsis" title="${item.text}">${item.text}</span>
<span tutor-dropdown-item data-key="${item.value}" class="tutor-nowrap-ellipsis" title="${tutor_esc_html(item.text)}">${tutor_esc_html(item.text)}</span>
</div>
`;
});
Expand Down
22 changes: 22 additions & 0 deletions assets/react/lib/tutor.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,28 @@ window.tutor_toast = function( title, description, type, autoClose = true ) {
}
};

/**
* Escape HTML and return safe HTML
*
* @since 2.2.4
*
* @param {string} unsafeText HTML string
* @returns string
*/
window.tutor_esc_html = function (unsafeText) {
let safeHTML = ''
let div = document.createElement('div');
/**
* When set an HTML string to an element's innerText
* the browser automatically escapes any HTML tags and
* treats the content as plain text.
*/
div.innerText = unsafeText;
safeHTML = div.innerHTML;
div.remove()

return safeHTML;
}

// enable custom selector when modal opens
window.addEventListener('tutor_modal_shown', (e) => {
Expand Down

0 comments on commit beaabf1

Please sign in to comment.