block tags starting with minus
This commit is contained in:
parent
4da207106b
commit
38406ef33a
1 changed files with 14 additions and 9 deletions
|
@ -581,11 +581,21 @@ class Image {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the tags for this image.
|
* Set the tags for this image.
|
||||||
*
|
|
||||||
* @param string[] $tags
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function set_tags(array $tags) {
|
public function set_tags(array $unfiltered_tags) {
|
||||||
|
$tags = [];
|
||||||
|
foreach ($unfiltered_tags as $tag) {
|
||||||
|
if(mb_strlen($tag, 'UTF-8') > 255){
|
||||||
|
flash_message("Can't set a tag longer than 255 characters");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(startsWith($tag, "-")) {
|
||||||
|
flash_message("Can't set a tag which starts with a minus");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tags[] = $tag;
|
||||||
|
}
|
||||||
assert('count($tags) > 0', var_export($tags, true));
|
assert('count($tags) > 0', var_export($tags, true));
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
|
@ -598,11 +608,6 @@ class Image {
|
||||||
$this->delete_tags_from_image();
|
$this->delete_tags_from_image();
|
||||||
// insert each new tags
|
// insert each new tags
|
||||||
foreach($tags as $tag) {
|
foreach($tags as $tag) {
|
||||||
if(mb_strlen($tag, 'UTF-8') > 255){
|
|
||||||
flash_message("The tag below is longer than 255 characters, please use a shorter tag.\n$tag\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = $database->get_one(
|
$id = $database->get_one(
|
||||||
$database->scoreql_to_sql("
|
$database->scoreql_to_sql("
|
||||||
SELECT id
|
SELECT id
|
||||||
|
|
Reference in a new issue