1
0
Эх сурвалжийг харах

fix: use null-prototype object for I18n translations lookup table

Object.create(null) ensures keys like '__proto__', 'constructor', and
'toString' are stored and retrieved as plain string keys rather than
shadowing Object prototype properties.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
rugk 1 сар өмнө
parent
commit
706b0325dc

+ 5 - 5
js/privatebin.js

@@ -688,7 +688,7 @@ window.PrivateBin = (function () {
          * @private
          * @private
          * @enum   {Object}
          * @enum   {Object}
          */
          */
-        let translations = {};
+        let translations = Object.create(null);
 
 
         /**
         /**
          * translate a string, alias for I18n.translate
          * translate a string, alias for I18n.translate
@@ -932,7 +932,7 @@ window.PrivateBin = (function () {
                 })
                 })
                 .then(data => {
                 .then(data => {
                     language = newLanguage;
                     language = newLanguage;
-                    translations = data;
+                    translations = Object.assign(Object.create(null), data);
                     document.dispatchEvent(new CustomEvent(languageLoadedEvent));
                     document.dispatchEvent(new CustomEvent(languageLoadedEvent));
                 })
                 })
                 .catch(error => {
                 .catch(error => {
@@ -949,7 +949,7 @@ window.PrivateBin = (function () {
          */
          */
         me.reset = function (mockLanguage, mockTranslations) {
         me.reset = function (mockLanguage, mockTranslations) {
             language = mockLanguage || null;
             language = mockLanguage || null;
-            translations = mockTranslations || {};
+            translations = mockTranslations || Object.create(null);
         };
         };
 
 
         /**
         /**
@@ -2219,8 +2219,8 @@ window.PrivateBin = (function () {
             loadconfirmClose.removeEventListener('click', Controller.newPaste);
             loadconfirmClose.removeEventListener('click', Controller.newPaste);
             loadconfirmClose.addEventListener('click', Controller.newPaste);
             loadconfirmClose.addEventListener('click', Controller.newPaste);
 
 
-            $loadconfirmmodal.on('shown.bs.modal', () => {
-                $loadconfirmOpenNow.trigger('focus');
+            loadconfirmmodal.addEventListener('shown.bs.modal', () => {
+                loadconfirmOpenNow.focus();
             });
             });
 
 
             if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip && typeof bootstrap.Modal === 'function') {
             if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip && typeof bootstrap.Modal === 'function') {