diff --git a/docker/doc.md b/docker/doc.md
index e022f170..051ae56e 100644
--- a/docker/doc.md
+++ b/docker/doc.md
@@ -14,3 +14,7 @@ The folder structure expected by compose is as follows
└── www
```
The vichan container is by itself much less rigid.
+
+
+Use `docker compose up --build` to start the docker compose.
+Use `docker compose up --build -d php` to rebuild just the vichan container while the compose is running. Useful for development.
diff --git a/inc/anti-bot.php b/inc/anti-bot.php
index 48150328..29279296 100644
--- a/inc/anti-bot.php
+++ b/inc/anti-bot.php
@@ -123,7 +123,7 @@ class AntiBot {
$html = '';
if ($count === false) {
- $count = mt_rand(1, abs(count($this->inputs) / 15) + 1);
+ $count = mt_rand(1, (int)abs(count($this->inputs) / 15) + 1);
}
if ($count === true) {
diff --git a/inc/functions.php b/inc/functions.php
index 1d98f9cf..61b85a96 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -1990,7 +1990,7 @@ function extract_modifiers($body) {
}
function remove_modifiers($body) {
- return preg_replace('@(.+?)@usm', '', $body);
+ return $body ? preg_replace('@(.+?)@usm', '', $body) : null;
}
function markup(&$body, $track_cites = false, $op = false) {
@@ -2259,6 +2259,7 @@ function escape_markup_modifiers($string) {
}
function defined_flags_accumulate($desired_flags) {
+ global $config;
$output_flags = 0x0;
foreach ($desired_flags as $flagname) {
if (defined($flagname)) {
@@ -2276,7 +2277,7 @@ function defined_flags_accumulate($desired_flags) {
function utf8tohtml($utf8) {
$flags = defined_flags_accumulate(['ENT_NOQUOTES', 'ENT_SUBSTITUTE', 'ENT_DISALLOWED']);
- return htmlspecialchars($utf8, $flags, 'UTF-8');
+ return $utf8 ? htmlspecialchars($utf8, $flags, 'UTF-8') : '';
}
function ordutf8($string, &$offset) {
diff --git a/inc/image.php b/inc/image.php
index 2429f682..840c9004 100644
--- a/inc/image.php
+++ b/inc/image.php
@@ -291,6 +291,7 @@ class ImageConvert extends ImageBase {
} else {
rename($this->temp, $src);
chmod($src, 0664);
+ $this->temp = false;
}
}
public function width() {
@@ -300,8 +301,10 @@ class ImageConvert extends ImageBase {
return $this->height;
}
public function destroy() {
- @unlink($this->temp);
- $this->temp = false;
+ if ($this->temp !== false) {
+ @unlink($this->temp);
+ $this->temp = false;
+ }
}
public function resize() {
global $config;
diff --git a/inc/mod/auth.php b/inc/mod/auth.php
index f95fbb86..46da5cdb 100644
--- a/inc/mod/auth.php
+++ b/inc/mod/auth.php
@@ -240,7 +240,7 @@ function check_login(bool $prompt = false): void {
$expected_cookie_name = calc_cookie_name($is_https, $is_path_jailed, $config['cookies']['mod']);
// Validate session
- if (isset($expected_cookie_name)) {
+ if (isset($_COOKIE[$expected_cookie_name])) {
// Should be username:hash:salt
$cookie = explode(':', $_COOKIE[$expected_cookie_name]);
if (count($cookie) != 3) {
diff --git a/post.php b/post.php
index aba6c6be..7babb04e 100644
--- a/post.php
+++ b/post.php
@@ -1055,9 +1055,11 @@ if (isset($_POST['delete'])) {
if ($size[0] > $config['max_width'] || $size[1] > $config['max_height']) {
error($config['error']['maxsize']);
}
+
// If, on the basis of the file extension, the image file has metadata we can operate on.
$file_image_has_operable_metadata = $file['extension'] === 'jpg' || $file['extension'] === 'jpeg' || $file['extension'] === 'webp' || $file['extension'] == 'png';
+ $file['exif_stripped'] = false;
if ($file_image_has_operable_metadata && $config['convert_auto_orient']) {
// The following code corrects the image orientation.
@@ -1123,7 +1125,7 @@ if (isset($_POST['delete'])) {
$dont_copy_file = false;
- if ($config['redraw_image'] || ($file_image_has_operable_metadata && !@$file['exif_stripped'] && $config['strip_exif'])) {
+ if ($config['redraw_image'] || ($file_image_has_operable_metadata && !$file['exif_stripped'] && $config['strip_exif'])) {
if (!$config['redraw_image'] && $config['use_exiftool']) {
try {
$file['size'] = strip_image_metadata($file['tmp_name']);
@@ -1319,14 +1321,22 @@ if (isset($_POST['delete'])) {
if (isset($_SERVER['HTTP_REFERER'])) {
// Tell Javascript that we posted successfully
- if (isset($_COOKIE[$config['cookies']['js']]))
+ if (isset($_COOKIE[$config['cookies']['js']])) {
$js = json_decode($_COOKIE[$config['cookies']['js']]);
- else
- $js = (object) array();
+ } else {
+ $js = (object)array();
+ }
// Tell it to delete the cached post for referer
$js->{$_SERVER['HTTP_REFERER']} = true;
- // Encode and set cookie
- setcookie($config['cookies']['js'], json_encode($js), 0, $config['cookies']['jail'] ? $config['cookies']['path'] : '/', null, false, false);
+
+ // Encode and set cookie.
+ $options = [
+ 'expires' => 0,
+ 'path' => $config['cookies']['jail'] ? $config['cookies']['path'] : '/',
+ 'httponly' => false,
+ 'samesite' => 'Strict'
+ ];
+ setcookie($config['cookies']['js'], json_encode($js), $options);
}
$root = $post['mod'] ? $config['root'] . $config['file_mod'] . '?/' : $config['root'];