فهرست منبع

Merge pull request #3326 from blink1073/fix-directory-traversal

Fix handling of missing directory
Afshin Darian 7 سال پیش
والد
کامیت
83b17558ee
2فایلهای تغییر یافته به همراه7 افزوده شده و 7 حذف شده
  1. 5 1
      packages/filebrowser/src/browser.ts
  2. 2 6
      packages/filebrowser/src/model.ts

+ 5 - 1
packages/filebrowser/src/browser.ts

@@ -270,7 +270,11 @@ class FileBrowser extends Widget {
       return;
     }
     this._showingError = true;
-    showErrorMessage('Server Connection Error', args).then(() => {
+    let title = 'Server Connection Error';
+    if (args.message.indexOf('Directory not found') === 0) {
+      title = 'Directory not found';
+    }
+    showErrorMessage(title, args).then(() => {
       this._showingError = false;
     });
   }

+ 2 - 6
packages/filebrowser/src/model.ts

@@ -227,13 +227,9 @@ class FileBrowserModel implements IDisposable {
     }).catch(error => {
       this._pendingPath = null;
       if (error.message === 'Not Found') {
-        let path = this._model.path;
-        error.message = `Directory not found: "${path}"`;
+        error.message = `Directory not found: "${this._model.path}"`;
         this._connectionFailure.emit(error);
-        let parent = PathExt.dirname(path);
-        if (parent !== path) {
-          this.cd('..');
-        }
+        this.cd('/');
       }
     });
     return this._pending;