[7.x] Handle encoding and decoding of angular route url components (#34300) (#35817)

This commit is contained in:
Eli Perelman 2019-05-29 10:24:38 -05:00 committed by GitHub
parent 2fabdbabe7
commit 5787d338b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 24 deletions

View file

@ -124,7 +124,7 @@
"@types/recompose": "^0.30.5",
"JSONStream": "1.1.1",
"abortcontroller-polyfill": "^1.1.9",
"angular": "1.6.9",
"angular": "npm:@elastic/angular@1.6.9-kibana.2",
"angular-aria": "1.6.6",
"angular-elastic": "2.5.0",
"angular-recursion": "^1.0.5",

View file

@ -17,8 +17,6 @@
* under the License.
*/
import url from 'url';
import {
getUnhashableStatesProvider,
unhashUrl,
@ -26,7 +24,7 @@ import {
import { onStart } from '../../new_platform';
export function registerSubUrlHooks(angularModule, internals) {
angularModule.run(($rootScope, Private, $location) => {
angularModule.run(($rootScope, Private) => {
const getUnhashableStates = Private(getUnhashableStatesProvider);
const subUrlRouteFilter = Private(SubUrlRouteFilterProvider);
@ -42,23 +40,6 @@ export function registerSubUrlHooks(angularModule, internals) {
}
}
$rootScope.$on('$locationChangeStart', (e, newUrl) => {
// This handler fixes issue #31238 where browser back navigation
// fails due to angular 1.6 parsing url encoded params wrong.
const parsedAbsUrl = url.parse($location.absUrl());
const absUrlHash = parsedAbsUrl.hash ? parsedAbsUrl.hash.slice(1) : '';
const decodedAbsUrlHash = decodeURIComponent(absUrlHash);
const parsedNewUrl = url.parse(newUrl);
const newHash = parsedNewUrl.hash ? parsedNewUrl.hash.slice(1) : '';
const decodedHash = decodeURIComponent(newHash);
if (absUrlHash !== newHash && decodedHash === decodedAbsUrlHash) {
// replace the urlencoded hash with the version that angular sees.
$location.url(absUrlHash).replace();
}
});
$rootScope.$on('$routeChangeSuccess', onRouteChange);
$rootScope.$on('$routeUpdate', onRouteChange);
onStart(updateSubUrls); // initialize sub urls

View file

@ -4538,11 +4538,16 @@ angular-ui-ace@0.2.3:
resolved "https://registry.yarnpkg.com/angular-ui-ace/-/angular-ui-ace-0.2.3.tgz#3cb903428100621a367fc7f641440e97a42a26d0"
integrity sha1-PLkDQoEAYho2f8f2QUQOl6QqJtA=
angular@1.6.9, angular@>=1.0.6:
angular@>=1.0.6:
version "1.6.9"
resolved "https://registry.yarnpkg.com/angular/-/angular-1.6.9.tgz#bc812932e18909038412d594a5990f4bb66c0619"
integrity sha512-6igWH2GIsxV+J38wNWCh8oyjaZsrIPIDO35twloIUyjlF2Yit6UyLAWujHP05ma/LFxTsx4NtYibRoMNBXPR1A==
"angular@npm:@elastic/angular@1.6.9-kibana.2":
version "1.6.9-kibana.2"
resolved "https://registry.yarnpkg.com/@elastic/angular/-/angular-1.6.9-kibana.2.tgz#ed27c3a26dc66b21d3454965a21e2265ab947fc7"
integrity sha512-wXWLOP+89ZzJNmRyo+H4Je0XG5VrRhDejfuxRKT8RLj4Xrfw9CvrgBGyW74kdFrsVU+99DKtZX+HuVFUkwf9TA==
ansi-align@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-2.0.0.tgz#c36aeccba563b89ceb556f3690f0b1d9e3547f7f"
@ -27449,8 +27454,6 @@ wbuf@^1.1.0, wbuf@^1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/wbuf/-/wbuf-1.7.2.tgz#d697b99f1f59512df2751be42769c1580b5801fe"
integrity sha1-1pe5nx9ZUS3ydRvkJ2nBWAtYAf4=
dependencies:
minimalistic-assert "^1.0.0"
wcwidth@^1.0.1:
version "1.0.1"