-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix removing all component tags #4602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,20 @@ class ComponentController extends Controller | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| protected $subMenu = []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Parse a comma-separated tags payload into a clean tag list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param string $tags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @return array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| protected function parseTags($tags) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+41
to
+46
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param string $tags | |
| * | |
| * @return array | |
| */ | |
| protected function parseTags($tags) | |
| { | |
| * @param mixed $tags | |
| * | |
| * @return array | |
| */ | |
| protected function parseTags($tags) | |
| { | |
| // If an array is provided (e.g. from a tags UI component), treat it as a list of tags. | |
| if (is_array($tags)) { | |
| $tagList = []; | |
| foreach ($tags as $tag) { | |
| // Only accept scalar or null-like values; ignore complex structures. | |
| if (!is_scalar($tag) && $tag !== null) { | |
| continue; | |
| } | |
| $value = trim((string) $tag); | |
| if ($value !== '') { | |
| $tagList[] = $value; | |
| } | |
| } | |
| return array_values($tagList); | |
| } | |
| // For non-array, non-scalar inputs, return an empty list instead of creating tags like "Array". | |
| if (!is_scalar($tags) && $tags !== null) { | |
| return []; | |
| } | |
| // Preserve existing behavior for scalar inputs by casting to string and splitting on commas. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseTags()casts$tagsto string; if a request submitstagsas an array (e.g.tags[]=a&tags[]=bor JSON array), PHP will cast it to the literal string "Array" and this code will create/sync a tag named "Array". Consider explicitly handling arrays (e.g. accept an array of tags) or rejecting non-scalar input with a 400 to avoid silently corrupting tag data.