From d13832400d1f1a25670ec56f7cdac1880743fabd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 17 May 2026 05:58:49 +0000 Subject: [PATCH 1/3] Initial plan From 5ebb1f0225b9e4e621e51c9be5ffb46f6ed84ef5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 17 May 2026 06:00:27 +0000 Subject: [PATCH 2/3] fix: allow rendering valueless HTML attributes Agent-Logs-Url: https://github.com/maxpertici/markup/sessions/33d47551-a128-48fb-ba92-0103db3992c5 Co-authored-by: maxpertici <48124450+maxpertici@users.noreply.github.com> --- docs/markup.md | 2 +- src/Markup.php | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/markup.md b/docs/markup.md index 50bb89f..d61509c 100644 --- a/docs/markup.md +++ b/docs/markup.md @@ -214,6 +214,7 @@ setAttribute(string $name, ?string $value): self $markup->setAttribute('id', 'main-content'); $markup->setAttribute('data-user-id', '123'); $markup->setAttribute('role', 'navigation'); +$markup->setAttribute('required', ''); // Remove an attribute (null value) $markup->setAttribute('disabled', null); @@ -1220,4 +1221,3 @@ $list = new Markup( - [MarkupQueryBuilder](markup-query-builder.html) - Fluent query builder - [MarkupCollection](markup-collection.html) - Collection methods - [Getting Started](getting-started.html) - Introduction and first steps - diff --git a/src/Markup.php b/src/Markup.php index 809e380..76dc771 100644 --- a/src/Markup.php +++ b/src/Markup.php @@ -664,7 +664,7 @@ public function classes( ?array $classes = null ) { * Sets or removes an HTML attribute on the wrapper element. * * If value is provided, sets the attribute. If value is null, removes the attribute. - * For boolean attributes (e.g., disabled, readonly), pass the attribute name as the value. + * For boolean attributes (e.g., disabled, readonly), pass an empty string as the value. * * @since 1.0.0 * @@ -1928,7 +1928,11 @@ private function wrapperOpenerTag(): string { if ( ! empty( $this->wrapperAttributes ) ) { $attributes = []; foreach ( $this->wrapperAttributes as $attribute => $value ) { - $attributes[] = $attribute . '="' . $value . '"'; + if ( '' === $value ) { + $attributes[] = $attribute; + } else { + $attributes[] = $attribute . '="' . $value . '"'; + } } $attributesStr = ' ' . implode( ' ', $attributes ); } else { @@ -2092,4 +2096,3 @@ private function renderSlot( MarkupSlot $slot ): string { } } - From 5440965bea2b0c4bde3e1410b2a84535779ae6c9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 17 May 2026 06:00:47 +0000 Subject: [PATCH 3/3] fix: escape attribute values during rendering Agent-Logs-Url: https://github.com/maxpertici/markup/sessions/33d47551-a128-48fb-ba92-0103db3992c5 Co-authored-by: maxpertici <48124450+maxpertici@users.noreply.github.com> --- src/Markup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Markup.php b/src/Markup.php index 76dc771..840e4f4 100644 --- a/src/Markup.php +++ b/src/Markup.php @@ -1931,7 +1931,7 @@ private function wrapperOpenerTag(): string { if ( '' === $value ) { $attributes[] = $attribute; } else { - $attributes[] = $attribute . '="' . $value . '"'; + $attributes[] = $attribute . '="' . htmlspecialchars( (string) $value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8' ) . '"'; } } $attributesStr = ' ' . implode( ' ', $attributes );