From 62ffd82aac0b218b736c71d200c502579b27aae5 Mon Sep 17 00:00:00 2001 From: Kevin Foster Date: Sun, 1 Sep 2024 08:02:12 +0100 Subject: [PATCH 1/7] Jquery bbq.js plugin - prevent proto injection --- framework/web/js/source/jquery.ba-bbq.js | 172 +++++-------------- framework/web/js/source/jquery.ba-bbq.min.js | 15 +- 2 files changed, 49 insertions(+), 138 deletions(-) diff --git a/framework/web/js/source/jquery.ba-bbq.js b/framework/web/js/source/jquery.ba-bbq.js index ead4ba1bd9..6ed01de199 100644 --- a/framework/web/js/source/jquery.ba-bbq.js +++ b/framework/web/js/source/jquery.ba-bbq.js @@ -1,36 +1,36 @@ /*! - * jQuery BBQ: Back Button & Query Library - v1.4pre - 1/15/2013 - * https://benalman.com/projects/jquery-bbq-plugin/ + * jQuery BBQ: Back Button & Query Library - v1.3pre - 8/26/2010 + * http://benalman.com/projects/jquery-bbq-plugin/ * - * Copyright (c) 2010-2013 "Cowboy" Ben Alman + * Copyright (c) 2010 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. - * https://benalman.com/about/license/ + * http://benalman.com/about/license/ */ // Script: jQuery BBQ: Back Button & Query Library // -// *Version: 1.4pre, Last updated: 1/15/2013* +// *Version: 1.3pre, Last updated: 8/26/2010* // -// Project Home - https://benalman.com/projects/jquery-bbq-plugin/ -// GitHub - https://github.com/cowboy/jquery-bbq/ -// Source - https://github.com/cowboy/jquery-bbq/raw/master/jquery.ba-bbq.js -// (Minified) - https://github.com/cowboy/jquery-bbq/raw/master/jquery.ba-bbq.min.js (2.2kb gzipped) +// Project Home - http://benalman.com/projects/jquery-bbq-plugin/ +// GitHub - http://github.com/cowboy/jquery-bbq/ +// Source - http://github.com/cowboy/jquery-bbq/raw/master/jquery.ba-bbq.js +// (Minified) - http://github.com/cowboy/jquery-bbq/raw/master/jquery.ba-bbq.min.js (2.2kb gzipped) // // About: License // -// Copyright (c) 2010-2013 "Cowboy" Ben Alman, +// Copyright (c) 2010 "Cowboy" Ben Alman, // Dual licensed under the MIT and GPL licenses. -// https://benalman.com/about/license/ +// http://benalman.com/about/license/ // // About: Examples // // These working examples, complete with fully commented code, illustrate a few // ways in which this plugin can be used. // -// Basic AJAX - https://benalman.com/code/projects/jquery-bbq/examples/fragment-basic/ -// Advanced AJAX - https://benalman.com/code/projects/jquery-bbq/examples/fragment-advanced/ -// jQuery UI Tabs - https://benalman.com/code/projects/jquery-bbq/examples/fragment-jquery-ui-tabs/ -// Deparam - https://benalman.com/code/projects/jquery-bbq/examples/deparam/ +// Basic AJAX - http://benalman.com/code/projects/jquery-bbq/examples/fragment-basic/ +// Advanced AJAX - http://benalman.com/code/projects/jquery-bbq/examples/fragment-advanced/ +// jQuery UI Tabs - http://benalman.com/code/projects/jquery-bbq/examples/fragment-jquery-ui-tabs/ +// Deparam - http://benalman.com/code/projects/jquery-bbq/examples/deparam/ // // About: Support and Testing // @@ -41,11 +41,10 @@ // jQuery Versions - 1.2.6, 1.3.2, 1.4.1, 1.4.2 // Browsers Tested - Internet Explorer 6-8, Firefox 2-4, Chrome 5-6, Safari 3.2-5, // Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5. -// Unit Tests - https://benalman.com/code/projects/jquery-bbq/unit/ +// Unit Tests - http://benalman.com/code/projects/jquery-bbq/unit/ // // About: Release History // -// 1.4pre - (1/15/2013) Removed $.browser reference to work with jQuery 1.9 // 1.3pre - (8/26/2010) Integrated v1.3, which adds // document.title and document.domain support in IE6/7, BlackBerry // support, better Iframe hiding for accessibility reasons, and the new @@ -342,7 +341,7 @@ // // obj - (Object) An object to be serialized. // traditional - (Boolean) Params deep/shallow serialization mode. See the - // documentation at https://api.jquery.com/jQuery.param/ for more detail. + // documentation at http://api.jquery.com/jQuery.param/ for more detail. // // Returns: // @@ -465,7 +464,9 @@ // (Object) An object representing the deserialized params string. $.deparam = jq_deparam = function( params, coerce ) { - var obj = {}, + var prohibitedKeys = ['__proto__']; + + var obj = Object.create(null), coerce_types = { 'true': !0, 'false': !1, 'null': null }; // Iterate over all name=value pairs. @@ -480,6 +481,10 @@ // into its component parts. keys = key.split( '][' ), keys_last = keys.length - 1; + + if (prohibitedKeys.includes(key)) { + return; + } // If the first keys part contains [ and the last ends with ], then [] // are correctly balanced. @@ -521,8 +526,13 @@ // * Rinse & repeat. for ( ; i <= keys_last; i++ ) { key = keys[i] === '' ? cur.length : keys[i]; + + if (prohibitedKeys.includes(key)) { + return; + } + cur = cur[key] = i < keys_last - ? cur[key] || ( keys[i+1] && isNaN( keys[i+1] ) ? {} : [] ) + ? cur[key] || ( keys[i+1] && isNaN( keys[i+1] ) ? Object.create(null) : [] ) : val; } @@ -988,36 +998,36 @@ /*! * jQuery hashchange event - v1.3 - 7/21/2010 - * https://benalman.com/projects/jquery-hashchange-plugin/ + * http://benalman.com/projects/jquery-hashchange-plugin/ * * Copyright (c) 2010 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. - * https://benalman.com/about/license/ + * http://benalman.com/about/license/ */ // Script: jQuery hashchange event // // *Version: 1.3, Last updated: 7/21/2010* // -// Project Home - https://benalman.com/projects/jquery-hashchange-plugin/ -// GitHub - https://github.com/cowboy/jquery-hashchange/ -// Source - https://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.js -// (Minified) - https://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.min.js (0.8kb gzipped) +// Project Home - http://benalman.com/projects/jquery-hashchange-plugin/ +// GitHub - http://github.com/cowboy/jquery-hashchange/ +// Source - http://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.js +// (Minified) - http://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.min.js (0.8kb gzipped) // // About: License // // Copyright (c) 2010 "Cowboy" Ben Alman, // Dual licensed under the MIT and GPL licenses. -// https://benalman.com/about/license/ +// http://benalman.com/about/license/ // // About: Examples // // These working examples, complete with fully commented code, illustrate a few // ways in which this plugin can be used. // -// hashchange event - https://benalman.com/code/projects/jquery-hashchange/examples/hashchange/ -// document.domain - https://benalman.com/code/projects/jquery-hashchange/examples/document_domain/ -// +// hashchange event - http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/ +// document.domain - http://benalman.com/code/projects/jquery-hashchange/examples/document_domain/ +// // About: Support and Testing // // Information about what version or versions of jQuery this plugin has been @@ -1027,7 +1037,7 @@ // jQuery Versions - 1.2.6, 1.3.2, 1.4.1, 1.4.2 // Browsers Tested - Internet Explorer 6-8, Firefox 2-4, Chrome 5-6, Safari 3.2-5, // Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5. -// Unit Tests - https://benalman.com/code/projects/jquery-hashchange/unit/ +// Unit Tests - http://benalman.com/code/projects/jquery-hashchange/unit/ // // About: Known issues // @@ -1037,10 +1047,10 @@ // window.onhashchange abstraction. See the following examples for more // information: // -// Chrome: Back Button - https://benalman.com/code/projects/jquery-hashchange/examples/bug-chrome-back-button/ -// Firefox: Remote XMLHttpRequest - https://benalman.com/code/projects/jquery-hashchange/examples/bug-firefox-remote-xhr/ -// WebKit: Back Button in an Iframe - https://benalman.com/code/projects/jquery-hashchange/examples/bug-webkit-hash-iframe/ -// Safari: Back Button from a different domain - https://benalman.com/code/projects/jquery-hashchange/examples/bug-safari-back-from-diff-domain/ +// Chrome: Back Button - http://benalman.com/code/projects/jquery-hashchange/examples/bug-chrome-back-button/ +// Firefox: Remote XMLHttpRequest - http://benalman.com/code/projects/jquery-hashchange/examples/bug-firefox-remote-xhr/ +// WebKit: Back Button in an Iframe - http://benalman.com/code/projects/jquery-hashchange/examples/bug-webkit-hash-iframe/ +// Safari: Back Button from a different domain - http://benalman.com/code/projects/jquery-hashchange/examples/bug-safari-back-from-diff-domain/ // // Also note that should a browser natively support the window.onhashchange // event, but not report that it does, the fallback polling loop will be used. @@ -1050,7 +1060,7 @@ // 1.3 - (7/21/2010) Reorganized IE6/7 Iframe code to make it more // "removable" for mobile-only development. Added IE6/7 document.title // support. Attempted to make Iframe as hidden as possible by using -// techniques from https://www.paciellogroup.com/blog/?p=604. Added +// techniques from http://www.paciellogroup.com/blog/?p=604. Added // support for the "shortcut" format $(window).hashchange( fn ) and // $(window).hashchange() like jQuery provides for built-in events. // Renamed jQuery.hashchangeDelay to and @@ -1282,96 +1292,6 @@ timeout_id = setTimeout( poll, $.fn[ str_hashchange ].delay ); }; - // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - // vvvvvvvvvvvvvvvvvvv REMOVE IF NOT SUPPORTING IE6/7/8 vvvvvvvvvvvvvvvvvvv - // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - (navigator.userAgent.match(/MSIE/i) !== null) && !supports_onhashchange && (function(){ - // Not only do IE6/7 need the "magical" Iframe treatment, but so does IE8 - // when running in "IE7 compatibility" mode. - - var iframe, - iframe_src; - - // When the event is bound and polling starts in IE 6/7, create a hidden - // Iframe for history handling. - self.start = function(){ - if ( !iframe ) { - iframe_src = $.fn[ str_hashchange ].src; - iframe_src = iframe_src && iframe_src + get_fragment(); - - // Create hidden Iframe. Attempt to make Iframe as hidden as possible - // by using techniques from https://www.paciellogroup.com/blog/?p=604. - iframe = $('