From 5466dcadc005e352db70956441aaee01cda7c780 Mon Sep 17 00:00:00 2001
From: Clark Tomlinson <fallen013@gmail.com>
Date: Fri, 19 Jun 2015 10:31:22 -0400
Subject: [PATCH] adding correct blocking logic for fff

---
 apps/files/js/filelist.js           |  8 ++++++++
 apps/files/tests/js/filelistSpec.js | 11 +++++++++++
 2 files changed, 19 insertions(+)

diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index b6f464bfd2..ab56b1a032 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -1123,6 +1123,14 @@
 				return false;
 			}
 
+			// Firewall Blocked request?
+			if (result.status === 403) {
+				// Go home
+				this.changeDirectory('/');
+				OC.Notification.show(t('files', 'This operation is forbidden'));
+				return false;
+			}
+
 			if (result.status === 404) {
 				// go back home
 				this.changeDirectory('/');
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index aa44c92792..6bcef8b6f4 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -1279,6 +1279,17 @@ describe('OCA.Files.FileList tests', function() {
 			fakeServer.respond();
 			expect(fileList.getCurrentDirectory()).toEqual('/');
 		});
+		it('switches to root dir when current directory is forbidden', function() {
+			fakeServer.respondWith(/\/index\.php\/apps\/files\/ajax\/list.php\?dir=%2funexist/, [
+				403, {
+					"Content-Type": "application/json"
+				},
+				''
+			]);
+			fileList.changeDirectory('/unexist');
+			fakeServer.respond();
+			expect(fileList.getCurrentDirectory()).toEqual('/');
+		});
 		it('shows mask before loading file list then hides it at the end', function() {
 			var showMaskStub = sinon.stub(fileList, 'showMask');
 			var hideMaskStub = sinon.stub(fileList, 'hideMask');
-- 
GitLab