Skip to content

Commit 7a5093c

Browse files
authored
Merge pull request #92 from nextcloud/stable9-fix-htaccess-warning
[stable9] Fix data directory warning
2 parents 326dcd7 + 6efe6b4 commit 7a5093c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

core/js/setupchecks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
}
198198
var afterCall = function(xhr) {
199199
var messages = [];
200-
if (xhr.status !== 403 && xhr.status !== 307 && xhr.status !== 301 && xhr.responseText !== '') {
200+
if (xhr.status !== 403 && xhr.status !== 307 && xhr.status !== 301 && xhr.responseText === 'This is used for testing whether htaccess is properly enabled to disallow access from the outside. This file can be safely removed.') {
201201
messages.push({
202202
msg: t('core', 'Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.'),
203203
type: OC.SetupChecks.MESSAGE_TYPE_ERROR

core/js/tests/specs/setupchecksSpec.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe('OC.SetupChecks tests', function() {
103103
it('should return an error if data directory is not protected', function(done) {
104104
var async = OC.SetupChecks.checkDataProtected();
105105

106-
suite.server.requests[0].respond(200, {'Content-Type': 'text/plain'}, 'file contents');
106+
suite.server.requests[0].respond(200, {'Content-Type': 'text/plain'}, 'This is used for testing whether htaccess is properly enabled to disallow access from the outside. This file can be safely removed.');
107107

108108
async.done(function( data, s, x ){
109109
expect(data).toEqual([
@@ -114,7 +114,18 @@ describe('OC.SetupChecks tests', function() {
114114
done();
115115
});
116116
});
117-
117+
118+
it('should return no error if data directory is protected and returns another content', function(done) {
119+
var async = OC.SetupChecks.checkDataProtected();
120+
121+
suite.server.requests[0].respond(200, {'Content-Type': 'text/plain'}, 'Another page');
122+
123+
async.done(function( data, s, x ){
124+
expect(data).toEqual([]);
125+
done();
126+
});
127+
});
128+
118129
it('should not return an error if data directory is protected', function(done) {
119130
var async = OC.SetupChecks.checkDataProtected();
120131

0 commit comments

Comments
 (0)