Skip to content

Commit

Permalink
[upload] fix empty-vs-null confusion, fixes shish#989
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Jan 5, 2024
1 parent f702506 commit 87368ac
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ext/upload/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,17 @@ private function tags_for_upload_slot(int $id): array

private function source_for_upload_slot(int $id): ?string
{
return $_POST["source$id"] ?? $_POST['source'] ?? null;
global $config;
if(!empty($_POST["source$id"])) {
return $_POST["source$id"];
}
if(!empty($_POST['source'])) {
return $_POST['source'];
}
if($config->get_bool(UploadConfig::TLSOURCE) && !empty($_POST["url$id"])) {
return $_POST["url$id"];
}
return null;
}

/**
Expand Down Expand Up @@ -409,7 +419,7 @@ private function try_transload(string $url, array $tags, string $source = null,
$metadata = [];
$metadata['filename'] = $filename;
$metadata['tags'] = $tags;
$metadata['source'] = (($url == $source) && !$config->get_bool(UploadConfig::TLSOURCE) ? "" : $source);
$metadata['source'] = $source;
if ($user->can(Permissions::EDIT_IMAGE_LOCK) && !empty($_GET['locked'])) {
$metadata['locked'] = bool_escape($_GET['locked']) ? "on" : "";
}
Expand Down

0 comments on commit 87368ac

Please sign in to comment.