Skip to content

Commit

Permalink
fixed security issue #1350 & #1349
Browse files Browse the repository at this point in the history
  • Loading branch information
JisanAR03 authored and DonnieBLT committed Nov 2, 2023
1 parent c336b74 commit d432204
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions website/static/js/jquery.caret.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,19 @@
$inputor = this.$inputor;
if (oDocument.selection) {
offset = this.getIEOffset(pos);
offset.top += $(oWindow).scrollTop() + $inputor.scrollTop();
offset.left += $(oWindow).scrollLeft() + $inputor.scrollLeft();
// Check if oWindow is a window object by checking for window-specific properties
function isValidWindow(obj) {
return obj && typeof obj === 'object' && 'scrollTo' in obj && obj.document && obj.self === obj;
}
// Then use this function in your conditionals
if (isValidWindow(oWindow)) {
offset.top += $(oWindow).scrollTop();
offset.left += $(oWindow).scrollLeft();
} else {
console.error('oWindow is not a valid window object.');
}
offset.top += $inputor.scrollTop();
offset.left += $inputor.scrollLeft();
return offset;
} else {
offset = $inputor.offset();
Expand Down

0 comments on commit d432204

Please sign in to comment.