Skip to content

Commit 85d8d10

Browse files
committed
Handle misconfigured password and destination folder.
Note that the API is a little weird for this. PhotoBackup/api#2
1 parent a8a9ef8 commit 85d8d10

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55
## [Unreleased]
66
### Added
77
- This CHANGELOG file.
8+
- Handle misconfigured password and destination folder.
89

910
### Changed
1011
- Handle duplicate files in the same way as the Python implementation, adding

index.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@
5757
exit();
5858
}
5959

60+
/**
61+
* Double check if a password has been configured. If there has not and we are
62+
* testing the server, exit with HTTP code 401. Otherwise treat it as an empty
63+
* string.
64+
*/
65+
if (!isset($Password) || !is_string($Password)) {
66+
if ($testing) {
67+
header($protocol . ' 401 Unauthorized');
68+
exit();
69+
}
70+
$Password = '';
71+
}
72+
6073
/**
6174
* If the client did not submit a password, or the submitted password did not
6275
* match this server's password, exit with HTTP code 403.
@@ -70,10 +83,12 @@
7083
}
7184

7285
/**
73-
* If the upload destination folder does not exist or is not writable by PHP,
74-
* exit with HTTP code 500.
86+
* If the upload destination folder has not been configured, does not exist, or
87+
* is not writable by PHP, exit with HTTP code 500.
7588
*/
7689
if (
90+
!isset($MediaRoot) ||
91+
!is_string($MediaRoot) ||
7792
!file_exists($MediaRoot) ||
7893
!is_dir($MediaRoot) ||
7994
!is_writable($MediaRoot)

0 commit comments

Comments
 (0)