Skip to content

Commit d432204

Browse files
JisanAR03DonnieBLT
authored andcommitted
fixed security issue #1350 & #1349
1 parent c336b74 commit d432204

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

website/static/js/jquery.caret.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,19 @@
216216
$inputor = this.$inputor;
217217
if (oDocument.selection) {
218218
offset = this.getIEOffset(pos);
219-
offset.top += $(oWindow).scrollTop() + $inputor.scrollTop();
220-
offset.left += $(oWindow).scrollLeft() + $inputor.scrollLeft();
219+
// Check if oWindow is a window object by checking for window-specific properties
220+
function isValidWindow(obj) {
221+
return obj && typeof obj === 'object' && 'scrollTo' in obj && obj.document && obj.self === obj;
222+
}
223+
// Then use this function in your conditionals
224+
if (isValidWindow(oWindow)) {
225+
offset.top += $(oWindow).scrollTop();
226+
offset.left += $(oWindow).scrollLeft();
227+
} else {
228+
console.error('oWindow is not a valid window object.');
229+
}
230+
offset.top += $inputor.scrollTop();
231+
offset.left += $inputor.scrollLeft();
221232
return offset;
222233
} else {
223234
offset = $inputor.offset();

0 commit comments

Comments
 (0)