fix: validate length of each tag

This commit is contained in:
Floorb 2023-02-27 05:37:39 -05:00
parent 49c5643bc7
commit 95885d6f5a
11 changed files with 21 additions and 6 deletions

View file

@ -89,6 +89,8 @@ class TagsInput {
this.inputNode.value = '' this.inputNode.value = ''
this.updateHiddenInputValue(); this.updateHiddenInputValue();
evt.preventDefault();
} else if (evt.key !== 'Backspace' && tagValue.length > 255) { // This could be improved to check if it would actually result in a new char being typed...
evt.preventDefault(); evt.preventDefault();
} }
} }

View file

@ -397,6 +397,8 @@ class TagsInput {
this.inputNode.value = ''; this.inputNode.value = '';
this.updateHiddenInputValue(); this.updateHiddenInputValue();
evt.preventDefault();
} else if (evt.key !== 'Backspace' && tagValue.length > 255) { // This could be improved to check if it would actually result in a new char being typed...
evt.preventDefault(); evt.preventDefault();
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -128,6 +128,8 @@ class TagsInput {
this.inputNode.value = ''; this.inputNode.value = '';
this.updateHiddenInputValue(); this.updateHiddenInputValue();
evt.preventDefault();
} else if (evt.key !== 'Backspace' && tagValue.length > 255) { // This could be improved to check if it would actually result in a new char being typed...
evt.preventDefault(); evt.preventDefault();
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -397,6 +397,8 @@ class TagsInput {
this.inputNode.value = ''; this.inputNode.value = '';
this.updateHiddenInputValue(); this.updateHiddenInputValue();
evt.preventDefault();
} else if (evt.key !== 'Backspace' && tagValue.length > 255) { // This could be improved to check if it would actually result in a new char being typed...
evt.preventDefault(); evt.preventDefault();
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -96,6 +96,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
goto OutPut; goto OutPut;
} }
foreach ($tags as $tag) {
if (strlen($tag) > 255) {
$error = 'A single tag cannot be longer than 255 characters.';
goto OutPut;
}
}
$editing = isset($_POST['edit']); $editing = isset($_POST['edit']);
$paste_title = trim($_POST['title']); $paste_title = trim($_POST['title']);