Fix directory traversal
This commit is contained in:
@@ -34,7 +34,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class extends IPCCon
|
||||
state = {
|
||||
active_directory: '/',
|
||||
items: [],
|
||||
previous_directory: '',
|
||||
previous: [],
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@@ -89,11 +89,16 @@ export default connect(mapStateToProps, mapDispatchToProps)(class extends IPCCon
|
||||
<div key={'dir_' + idx} style={{...style}}>
|
||||
<Button buttonStyles={{textAlign: 'left'}}
|
||||
clicked={() => {
|
||||
const current_path = path === '..' ? '' : this.state.active_directory;
|
||||
const previous = [...this.state.previous];
|
||||
if (path === '..') {
|
||||
path = previous.pop();
|
||||
} else {
|
||||
previous.push(this.state.active_directory);
|
||||
}
|
||||
this.setState({
|
||||
items: [],
|
||||
active_directory: path === '..' ? this.state.previous_directory : path,
|
||||
previous_directory: current_path,
|
||||
active_directory: path,
|
||||
previous,
|
||||
}, () => {
|
||||
this.grabDirectoryItems();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user