From 191faa46787c728ee1d950fc885ac9d0a62e86f7 Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Mon, 24 Jul 2017 15:01:11 +0200 Subject: [PATCH 1/3] fix correct encoding/decoding of folder urls in the browser history --- build/libifm.php | 4 ++-- ifm.php | 4 ++-- src/ifm.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/libifm.php b/build/libifm.php index 615ea7e..abdafd8 100644 --- a/build/libifm.php +++ b/build/libifm.php @@ -966,7 +966,7 @@ function IFM( params ) { self.currentDir = data.realpath; self.refreshFileTable(); $( "#currentDir" ).val( self.currentDir ); - if( config.pushState ) history.pushState( { dir: self.currentDir }, self.currentDir, "#"+self.currentDir ); + if( config.pushState ) history.pushState( { dir: self.currentDir }, self.currentDir, "#"+encodeURIComponent( self.currentDir ) ); }, error: function() { self.showMessage( "General error occured: No or broken response", "e" ); } }); @@ -1772,7 +1772,7 @@ function IFM( params ) { */ this.historyPopstateHandler = function(event) { var dir = ""; - if( event.state && event.state.dir ) dir = event.state.dir; + if( event.state && event.state.dir ) dir = decodeURIComponent( event.state.dir ); self.changeDirectory( dir, { pushState: false, absolute: true } ); }; diff --git a/ifm.php b/ifm.php index bc58f15..a1ec207 100644 --- a/ifm.php +++ b/ifm.php @@ -966,7 +966,7 @@ function IFM( params ) { self.currentDir = data.realpath; self.refreshFileTable(); $( "#currentDir" ).val( self.currentDir ); - if( config.pushState ) history.pushState( { dir: self.currentDir }, self.currentDir, "#"+self.currentDir ); + if( config.pushState ) history.pushState( { dir: self.currentDir }, self.currentDir, "#"+encodeURIComponent( self.currentDir ) ); }, error: function() { self.showMessage( "General error occured: No or broken response", "e" ); } }); @@ -1772,7 +1772,7 @@ function IFM( params ) { */ this.historyPopstateHandler = function(event) { var dir = ""; - if( event.state && event.state.dir ) dir = event.state.dir; + if( event.state && event.state.dir ) dir = decodeURIComponent( event.state.dir ); self.changeDirectory( dir, { pushState: false, absolute: true } ); }; diff --git a/src/ifm.js b/src/ifm.js index 44b4147..9a2e2e1 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -228,7 +228,7 @@ function IFM( params ) { self.currentDir = data.realpath; self.refreshFileTable(); $( "#currentDir" ).val( self.currentDir ); - if( config.pushState ) history.pushState( { dir: self.currentDir }, self.currentDir, "#"+self.currentDir ); + if( config.pushState ) history.pushState( { dir: self.currentDir }, self.currentDir, "#"+encodeURIComponent( self.currentDir ) ); }, error: function() { self.showMessage( "General error occured: No or broken response", "e" ); } }); @@ -1034,7 +1034,7 @@ function IFM( params ) { */ this.historyPopstateHandler = function(event) { var dir = ""; - if( event.state && event.state.dir ) dir = event.state.dir; + if( event.state && event.state.dir ) dir = decodeURIComponent( event.state.dir ); self.changeDirectory( dir, { pushState: false, absolute: true } ); }; From 0eab5b3777ddaac2543615a04e9be0e052186ee8 Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Mon, 24 Jul 2017 15:26:05 +0200 Subject: [PATCH 2/3] fix missing encoding for initial chdir --- build/libifm.php | 6 ++++-- ifm.php | 6 ++++-- src/ifm.js | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/build/libifm.php b/build/libifm.php index abdafd8..59cb5a9 100644 --- a/build/libifm.php +++ b/build/libifm.php @@ -1772,7 +1772,9 @@ function IFM( params ) { */ this.historyPopstateHandler = function(event) { var dir = ""; - if( event.state && event.state.dir ) dir = decodeURIComponent( event.state.dir ); + if( event.state && event.state.dir ) { + dir = event.state.dir; + } self.changeDirectory( dir, { pushState: false, absolute: true } ); }; @@ -2048,7 +2050,7 @@ function IFM( params ) { window.onpopstate = self.historyPopstateHandler; // load initial file table if( window.location.hash ) { - self.changeDirectory( window.location.hash.substring( 1 ) ); + self.changeDirectory( decodeURIComponent( window.location.hash.substring( 1 ) ) ); } else { this.refreshFileTable(); } diff --git a/ifm.php b/ifm.php index a1ec207..425e5aa 100644 --- a/ifm.php +++ b/ifm.php @@ -1772,7 +1772,9 @@ function IFM( params ) { */ this.historyPopstateHandler = function(event) { var dir = ""; - if( event.state && event.state.dir ) dir = decodeURIComponent( event.state.dir ); + if( event.state && event.state.dir ) { + dir = event.state.dir; + } self.changeDirectory( dir, { pushState: false, absolute: true } ); }; @@ -2048,7 +2050,7 @@ function IFM( params ) { window.onpopstate = self.historyPopstateHandler; // load initial file table if( window.location.hash ) { - self.changeDirectory( window.location.hash.substring( 1 ) ); + self.changeDirectory( decodeURIComponent( window.location.hash.substring( 1 ) ) ); } else { this.refreshFileTable(); } diff --git a/src/ifm.js b/src/ifm.js index 9a2e2e1..b8a7b17 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -1034,7 +1034,9 @@ function IFM( params ) { */ this.historyPopstateHandler = function(event) { var dir = ""; - if( event.state && event.state.dir ) dir = decodeURIComponent( event.state.dir ); + if( event.state && event.state.dir ) { + dir = event.state.dir; + } self.changeDirectory( dir, { pushState: false, absolute: true } ); }; @@ -1310,7 +1312,7 @@ function IFM( params ) { window.onpopstate = self.historyPopstateHandler; // load initial file table if( window.location.hash ) { - self.changeDirectory( window.location.hash.substring( 1 ) ); + self.changeDirectory( decodeURIComponent( window.location.hash.substring( 1 ) ) ); } else { this.refreshFileTable(); } From ab31ade0423f8587bced6135769f40666932a65e Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Mon, 24 Jul 2017 15:26:05 +0200 Subject: [PATCH 3/3] fix missing encoding for initial chdir --- build/libifm.php | 5 +++-- ifm.php | 5 +++-- src/ifm.js | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build/libifm.php b/build/libifm.php index abdafd8..81f0faa 100644 --- a/build/libifm.php +++ b/build/libifm.php @@ -1772,7 +1772,8 @@ function IFM( params ) { */ this.historyPopstateHandler = function(event) { var dir = ""; - if( event.state && event.state.dir ) dir = decodeURIComponent( event.state.dir ); + if( event.state && event.state.dir ) + dir = event.state.dir; self.changeDirectory( dir, { pushState: false, absolute: true } ); }; @@ -2048,7 +2049,7 @@ function IFM( params ) { window.onpopstate = self.historyPopstateHandler; // load initial file table if( window.location.hash ) { - self.changeDirectory( window.location.hash.substring( 1 ) ); + self.changeDirectory( decodeURIComponent( window.location.hash.substring( 1 ) ) ); } else { this.refreshFileTable(); } diff --git a/ifm.php b/ifm.php index a1ec207..c53339a 100644 --- a/ifm.php +++ b/ifm.php @@ -1772,7 +1772,8 @@ function IFM( params ) { */ this.historyPopstateHandler = function(event) { var dir = ""; - if( event.state && event.state.dir ) dir = decodeURIComponent( event.state.dir ); + if( event.state && event.state.dir ) + dir = event.state.dir; self.changeDirectory( dir, { pushState: false, absolute: true } ); }; @@ -2048,7 +2049,7 @@ function IFM( params ) { window.onpopstate = self.historyPopstateHandler; // load initial file table if( window.location.hash ) { - self.changeDirectory( window.location.hash.substring( 1 ) ); + self.changeDirectory( decodeURIComponent( window.location.hash.substring( 1 ) ) ); } else { this.refreshFileTable(); } diff --git a/src/ifm.js b/src/ifm.js index 9a2e2e1..9e8592b 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -1034,7 +1034,8 @@ function IFM( params ) { */ this.historyPopstateHandler = function(event) { var dir = ""; - if( event.state && event.state.dir ) dir = decodeURIComponent( event.state.dir ); + if( event.state && event.state.dir ) + dir = event.state.dir; self.changeDirectory( dir, { pushState: false, absolute: true } ); }; @@ -1310,7 +1311,7 @@ function IFM( params ) { window.onpopstate = self.historyPopstateHandler; // load initial file table if( window.location.hash ) { - self.changeDirectory( window.location.hash.substring( 1 ) ); + self.changeDirectory( decodeURIComponent( window.location.hash.substring( 1 ) ) ); } else { this.refreshFileTable(); }