diff options
author | dizzy <diosmosis@users.noreply.github.com> | 2022-06-01 08:20:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-01 08:20:06 +0300 |
commit | 9d4e0edabafe9033e388a66ad0cf0ae62530ad02 (patch) | |
tree | 3818aa425ba2e82cbbb84e6d9a16fb146f81bf2e /plugins/CoreHome | |
parent | 70b004c968a1850b65c71156b465d189f4692a49 (diff) |
make sure spaces are encoded as %20 in URLs since some parts of matomo do not decode + properly (#19299)
Diffstat (limited to 'plugins/CoreHome')
-rw-r--r-- | plugins/CoreHome/vue/dist/CoreHome.umd.js | 4 | ||||
-rw-r--r-- | plugins/CoreHome/vue/dist/CoreHome.umd.min.js | 2 | ||||
-rw-r--r-- | plugins/CoreHome/vue/src/MatomoUrl/MatomoUrl.ts | 5 |
3 files changed, 8 insertions, 3 deletions
diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.js b/plugins/CoreHome/vue/dist/CoreHome.umd.js index 310f0abc13..f2cbbb42dc 100644 --- a/plugins/CoreHome/vue/dist/CoreHome.umd.js +++ b/plugins/CoreHome/vue/dist/CoreHome.umd.js @@ -1249,7 +1249,9 @@ var MatomoUrl_MatomoUrl = /*#__PURE__*/function () { return $.param(searchWithoutEmpty).replace(/%5B%5D/g, '[]') // some browsers treat URLs w/ date=a,b differently from date=a%2Cb, causing multiple // entries to show up in the browser history. this has a compounding effect w/ angular.js, // which when the back button is pressed to effectively abort the back navigation. - .replace(/%2C/g, ','); + .replace(/%2C/g, ',') // jquery seems to encode space characters as '+', but certain parts of matomo won't + // decode it correctly, so we make sure to use %20 instead + .replace(/\+/g, '%20'); } }, { key: "updatePeriodParamsFromUrl", diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.min.js b/plugins/CoreHome/vue/dist/CoreHome.umd.min.js index b191fe8bd5..2e62fd9275 100644 --- a/plugins/CoreHome/vue/dist/CoreHome.umd.min.js +++ b/plugins/CoreHome/vue/dist/CoreHome.umd.min.js @@ -79,7 +79,7 @@ function ue(e,t){return he(e)||fe(e,t)||pe(e,t)||de()}function de(){throw new Ty * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */p.addCustomPeriod("year",se);var we=window,Oe=we.piwik,je=we.broadcast;function ke(e,t){try{return p.parse(e,t),!0}catch(n){return!1}}var Se=function(){function e(){var t=this;ge(this,e),ye(this,"urlQuery",Object(a["ref"])("")),ye(this,"hashQuery",Object(a["ref"])("")),ye(this,"urlParsed",Object(a["computed"])((function(){return Object(a["readonly"])(t.parse(t.urlQuery.value))}))),ye(this,"hashParsed",Object(a["computed"])((function(){return Object(a["readonly"])(t.parse(t.hashQuery.value))}))),ye(this,"parsed",Object(a["computed"])((function(){return Object(a["readonly"])(Object.assign(Object.assign({},t.urlParsed.value),t.hashParsed.value))}))),this.setUrlQuery(window.location.search),this.setHashQuery(window.location.hash),S.on("$locationChangeSuccess",(function(e){var n=new URL(e);t.setUrlQuery(n.search.replace(/^\?/,"")),t.setHashQuery(n.hash.replace(/^#/,""))})),this.updatePeriodParamsFromUrl()}return be(e,[{key:"updateHashToUrl",value:function(e){var t=S.helper.getAngularDependency("$location");t.url(e)}},{key:"updateHash",value:function(e){var t=this.getFinalHashParams(e),n=this.stringify(t),r=S.helper.getAngularDependency("$location");r.search(n);var i=S.helper.getAngularDependency("$timeout");i()}},{key:"updateUrl",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="string"!==typeof e?this.stringify(e):e,r=Object.keys(t).length?this.getFinalHashParams(t,e):{},i=this.stringify(r),a="?".concat(n);i.length&&(a="".concat(a,"#?").concat(i)),window.broadcast.propagateNewPage("",void 0,void 0,void 0,a)}},{key:"getFinalHashParams",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="string"!==typeof e?e:this.parse(e),r="string"!==typeof e?t:this.parse(t);return Object.assign({period:r.period||this.parsed.value.period,date:r.date||this.parsed.value.date,segment:r.segment||this.parsed.value.segment},n)}},{key:"updateLocation",value:function(e){S.helper.isAngularRenderingThePage()?this.updateHash(e):this.updateUrl(e)}},{key:"getSearchParam",value:function(e){var t=window.location.href.split("#"),n=new RegExp("".concat(e,"(\\[]|=)"));if(t&&t[1]&&n.test(decodeURIComponent(t[1]))){var r=window.broadcast.getValueFromHash(e,window.location.href);if(r||"date"!==e&&"period"!==e&&"idSite"!==e)return r}return window.broadcast.getValueFromUrl(e,window.location.search)}},{key:"parse",value:function(e){return je.getValuesFromUrl("?".concat(e),!0)}},{key:"stringify",value:function(e){var t=Object.fromEntries(Object.entries(e).filter((function(e){var t=ue(e,2),n=t[1];return""!==n&&null!==n&&void 0!==n})));return $.param(t).replace(/%5B%5D/g,"[]").replace(/%2C/g,",")}},{key:"updatePeriodParamsFromUrl",value:function(){var e=this.getSearchParam("date"),t=this.getSearchParam("period");if(ke(t,e)&&(Oe.period!==t||Oe.currentDateString!==e)){Oe.period=t;var n=p.parse(t,e).getDateRange();Oe.startDateString=D(n[0]),Oe.endDateString=D(n[1]),Oe.updateDateInTitle(e,t),"range"===Oe.period&&(e="".concat(Oe.startDateString,",").concat(Oe.endDateString)),Oe.currentDateString=e}}},{key:"setUrlQuery",value:function(e){this.urlQuery.value=e.replace(/^\?/,"")}},{key:"setHashQuery",value:function(e){this.hashQuery.value=e.replace(/^[#/?]+/,"")}}]),e}(),Ce=new Se,Ee=Ce; + */p.addCustomPeriod("year",se);var we=window,Oe=we.piwik,je=we.broadcast;function ke(e,t){try{return p.parse(e,t),!0}catch(n){return!1}}var Se=function(){function e(){var t=this;ge(this,e),ye(this,"urlQuery",Object(a["ref"])("")),ye(this,"hashQuery",Object(a["ref"])("")),ye(this,"urlParsed",Object(a["computed"])((function(){return Object(a["readonly"])(t.parse(t.urlQuery.value))}))),ye(this,"hashParsed",Object(a["computed"])((function(){return Object(a["readonly"])(t.parse(t.hashQuery.value))}))),ye(this,"parsed",Object(a["computed"])((function(){return Object(a["readonly"])(Object.assign(Object.assign({},t.urlParsed.value),t.hashParsed.value))}))),this.setUrlQuery(window.location.search),this.setHashQuery(window.location.hash),S.on("$locationChangeSuccess",(function(e){var n=new URL(e);t.setUrlQuery(n.search.replace(/^\?/,"")),t.setHashQuery(n.hash.replace(/^#/,""))})),this.updatePeriodParamsFromUrl()}return be(e,[{key:"updateHashToUrl",value:function(e){var t=S.helper.getAngularDependency("$location");t.url(e)}},{key:"updateHash",value:function(e){var t=this.getFinalHashParams(e),n=this.stringify(t),r=S.helper.getAngularDependency("$location");r.search(n);var i=S.helper.getAngularDependency("$timeout");i()}},{key:"updateUrl",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="string"!==typeof e?this.stringify(e):e,r=Object.keys(t).length?this.getFinalHashParams(t,e):{},i=this.stringify(r),a="?".concat(n);i.length&&(a="".concat(a,"#?").concat(i)),window.broadcast.propagateNewPage("",void 0,void 0,void 0,a)}},{key:"getFinalHashParams",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="string"!==typeof e?e:this.parse(e),r="string"!==typeof e?t:this.parse(t);return Object.assign({period:r.period||this.parsed.value.period,date:r.date||this.parsed.value.date,segment:r.segment||this.parsed.value.segment},n)}},{key:"updateLocation",value:function(e){S.helper.isAngularRenderingThePage()?this.updateHash(e):this.updateUrl(e)}},{key:"getSearchParam",value:function(e){var t=window.location.href.split("#"),n=new RegExp("".concat(e,"(\\[]|=)"));if(t&&t[1]&&n.test(decodeURIComponent(t[1]))){var r=window.broadcast.getValueFromHash(e,window.location.href);if(r||"date"!==e&&"period"!==e&&"idSite"!==e)return r}return window.broadcast.getValueFromUrl(e,window.location.search)}},{key:"parse",value:function(e){return je.getValuesFromUrl("?".concat(e),!0)}},{key:"stringify",value:function(e){var t=Object.fromEntries(Object.entries(e).filter((function(e){var t=ue(e,2),n=t[1];return""!==n&&null!==n&&void 0!==n})));return $.param(t).replace(/%5B%5D/g,"[]").replace(/%2C/g,",").replace(/\+/g,"%20")}},{key:"updatePeriodParamsFromUrl",value:function(){var e=this.getSearchParam("date"),t=this.getSearchParam("period");if(ke(t,e)&&(Oe.period!==t||Oe.currentDateString!==e)){Oe.period=t;var n=p.parse(t,e).getDateRange();Oe.startDateString=D(n[0]),Oe.endDateString=D(n[1]),Oe.updateDateInTitle(e,t),"range"===Oe.period&&(e="".concat(Oe.startDateString,",").concat(Oe.endDateString)),Oe.currentDateString=e}}},{key:"setUrlQuery",value:function(e){this.urlQuery.value=e.replace(/^\?/,"")}},{key:"setHashQuery",value:function(e){this.hashQuery.value=e.replace(/^[#/?]+/,"")}}]),e}(),Ce=new Se,Ee=Ce; /*! * Matomo - free/libre analytics platform * diff --git a/plugins/CoreHome/vue/src/MatomoUrl/MatomoUrl.ts b/plugins/CoreHome/vue/src/MatomoUrl/MatomoUrl.ts index 9ab1dc54aa..4d881450ff 100644 --- a/plugins/CoreHome/vue/src/MatomoUrl/MatomoUrl.ts +++ b/plugins/CoreHome/vue/src/MatomoUrl/MatomoUrl.ts @@ -158,7 +158,10 @@ class MatomoUrl { // some browsers treat URLs w/ date=a,b differently from date=a%2Cb, causing multiple // entries to show up in the browser history. this has a compounding effect w/ angular.js, // which when the back button is pressed to effectively abort the back navigation. - .replace(/%2C/g, ','); + .replace(/%2C/g, ',') + // jquery seems to encode space characters as '+', but certain parts of matomo won't + // decode it correctly, so we make sure to use %20 instead + .replace(/\+/g, '%20'); } updatePeriodParamsFromUrl(): void { |