Skip to content

Commit

Permalink
Add screenshot MIME type setting
Browse files Browse the repository at this point in the history
  • Loading branch information
migueldemoura committed Dec 4, 2018
1 parent bda1f3d commit 9decd32
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,26 @@ If an external file is found, Myazo extends the default config with the provided
* Example Config: `client/config.php.example`
* Placement Path: `~/.config/myazo/config.ini` (`~` refers to the user directory)

| Key | Default | Description |
|-------------------|----------------------------------------|-----------------------------------------------------|
| upload_script | 'https://myazo.example.com/upload.php' | Full path to the upload.php file |
| secret | 'hunter2' | Secret token |
| clear_metadata | True | Controls clearing screenshot metadata before upload |
| open_browser | True | Controls open url in default browser after upload |
| copy_clipboard | True | Controls copy url to clipboard after upload |
| output_url | True | Controls print url to stdout after upload |
| Key | Default | Description |
|--------------------|----------------------------------------|-----------------------------------------------------|
| upload_script | 'https://myazo.example.com/upload.php' | Full path to the upload.php file |
| secret | 'hunter2' | Secret token |
| clear_metadata | True | Controls clearing screenshot metadata before upload |
| open_browser | True | Controls open url in default browser after upload |
| copy_clipboard | True | Controls copy url to clipboard after upload |
| output_url | True | Controls print url to stdout after upload |

### Server

* Example Config: `server/config.php.example`
* Placement Path: `config.php` (relative to `upload.php`)

| Key | Default | Description |
|-------------------|----------------------------------------|-----------------------------------------------------|
| secretBcrypt | '' | Bcrypt hashed secret |
| saveDirName | '/data/' | Writable directory where screenshots will be stored |
| maxScreenshotSize | 2 * 1048576 | Maximum size in bytes of uploaded screenshot |
| Key | Default | Description |
|--------------------|----------------------------------------|-----------------------------------------------------|
| secretBcrypt | '' | Bcrypt hashed secret |
| saveDirName | '/data/' | Writable directory where screenshots will be stored |
| maxScreenshotSize | 2 * 1048576 | Maximum size in bytes of uploaded screenshot |
| screenshotMimeType | 'image/png' | MIME type of uploaded screenshot |

Please note that `maxScreenshotSize` may be capped externally by PHP and the web server.

Expand Down
3 changes: 2 additions & 1 deletion server/config.php.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
return [
'secretBcrypt' => '',
'saveDirName' => '/data/',
'maxScreenshotSize' => 2 * 1048576
'maxScreenshotSize' => 2 * 1048576,
'screenshotMimeType' => 'image/png'
];
5 changes: 3 additions & 2 deletions server/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[
'secretBcrypt' => '',
'saveDirName' => '/data/',
'maxScreenshotSize' => 2 * 1048576
'maxScreenshotSize' => 2 * 1048576,
'screenshotMimeType' => 'image/png'
],
file_exists('./config.php') ? include_once('./config.php') : []
);
Expand All @@ -26,7 +27,7 @@
$screenshot['error'] !== UPLOAD_ERR_OK ||
// Verify size and mime type
$screenshot['size'] > $config['maxScreenshotSize'] ||
mime_content_type($screenshot['tmp_name']) !== 'image/png'
mime_content_type($screenshot['tmp_name']) !== $config['screenshotMimeType']
) {
http_response_code(422);
exit();
Expand Down

0 comments on commit 9decd32

Please sign in to comment.