Throw error if album name is too large

Fixes #534
This commit is contained in:
Celestora 2022-04-18 19:02:23 +03:00
parent cacc223eb9
commit e66a96be6e
3 changed files with 7 additions and 0 deletions

View file

@ -72,6 +72,8 @@ final class PhotosPresenter extends OpenVKPresenter
if($_SERVER["REQUEST_METHOD"] === "POST") { if($_SERVER["REQUEST_METHOD"] === "POST") {
if(empty($this->postParam("name"))) if(empty($this->postParam("name")))
$this->flashFail("err", tr("error"), tr("error_segmentation")); $this->flashFail("err", tr("error"), tr("error_segmentation"));
else if(strlen($this->postParam("name")) > 36)
$this->flashFail("err", tr("error"), tr("error_data_too_big", "name", 36, "bytes"));
$album = new Album; $album = new Album;
$album->setOwner(isset($club) ? $club->getId() * -1 : $this->user->id); $album->setOwner(isset($club) ? $club->getId() * -1 : $this->user->id);
@ -100,6 +102,9 @@ final class PhotosPresenter extends OpenVKPresenter
$this->template->album = $album; $this->template->album = $album;
if($_SERVER["REQUEST_METHOD"] === "POST") { if($_SERVER["REQUEST_METHOD"] === "POST") {
if(strlen($this->postParam("name")) > 36)
$this->flashFail("err", tr("error"), tr("error_data_too_big", "name", 36, "bytes"));
$album->setName(empty($this->postParam("name")) ? $album->getName() : $this->postParam("name")); $album->setName(empty($this->postParam("name")) ? $album->getName() : $this->postParam("name"));
$album->setDescription(empty($this->postParam("desc")) ? NULL : $this->postParam("desc")); $album->setDescription(empty($this->postParam("desc")) ? NULL : $this->postParam("desc"));
$album->setEdited(time()); $album->setEdited(time());

View file

@ -776,6 +776,7 @@
"error_new_password" = "New password does not match"; "error_new_password" = "New password does not match";
"error_shorturl_incorrect" = "The short address has an incorrect format."; "error_shorturl_incorrect" = "The short address has an incorrect format.";
"error_repost_fail" = "Failed to share post"; "error_repost_fail" = "Failed to share post";
"error_data_too_big" = "Attribute '$1' must be at most $2 $3 long";
"forbidden" = "Access error"; "forbidden" = "Access error";
"forbidden_comment" = "This user's privacy settings do not allow you to look at his page."; "forbidden_comment" = "This user's privacy settings do not allow you to look at his page.";

View file

@ -819,6 +819,7 @@
"error_new_password" = "Новые пароли не совпадает"; "error_new_password" = "Новые пароли не совпадает";
"error_shorturl_incorrect" = "Короткий адрес имеет некорректный формат."; "error_shorturl_incorrect" = "Короткий адрес имеет некорректный формат.";
"error_repost_fail" = "Не удалось поделиться записью"; "error_repost_fail" = "Не удалось поделиться записью";
"error_data_too_big" = "Аттрибут '$1' не может быть длиннее $2 $3";
"forbidden" = "Ошибка доступа"; "forbidden" = "Ошибка доступа";
"forbidden_comment" = "Настройки приватности этого пользователя не разрешают вам смотреть на его страницу."; "forbidden_comment" = "Настройки приватности этого пользователя не разрешают вам смотреть на его страницу.";