fix: DockerSecretsResolver - don't normalize absolute paths like /var/www/html/...
Some checks failed
Deploy Application / deploy (push) Has been cancelled

This commit is contained in:
2025-11-24 21:28:25 +01:00
parent 4eb7134853
commit 77abc65cd7
1327 changed files with 91915 additions and 9909 deletions

View File

@@ -5,6 +5,8 @@ declare(strict_types=1);
namespace App\Framework\View\Components;
use App\Framework\View\Attributes\ComponentName;
use App\Framework\View\Components\Helpers\ComponentAttributeHelper;
use App\Framework\View\Components\Helpers\ComponentClassBuilder;
use App\Framework\View\Contracts\StaticComponent;
use App\Framework\View\Dom\ElementNode;
use App\Framework\View\Dom\Node;
@@ -20,6 +22,7 @@ final readonly class Card implements StaticComponent
private ?string $imageSrc;
private ?string $imageAlt;
private string $variant;
private array $attributes;
public function __construct(
string $content = '',
@@ -27,23 +30,38 @@ final readonly class Card implements StaticComponent
) {
// Content is the card body
$this->bodyContent = $content;
$this->attributes = $attributes;
// Extract attributes with defaults
$this->title = $attributes['title'] ?? null;
$this->subtitle = $attributes['subtitle'] ?? null;
$this->footer = $attributes['footer'] ?? null;
$this->imageSrc = $attributes['image-src'] ?? null;
$this->imageAlt = $attributes['image-alt'] ?? null;
$this->variant = $attributes['variant'] ?? 'default';
// Extract attributes using Helper
$this->variant = ComponentAttributeHelper::extractVariant($attributes, 'default');
$this->title = ComponentAttributeHelper::extractString($attributes, 'title');
$this->subtitle = ComponentAttributeHelper::extractString($attributes, 'subtitle');
$this->footer = ComponentAttributeHelper::extractString($attributes, 'footer');
$this->imageSrc = ComponentAttributeHelper::extractString($attributes, 'image-src');
$this->imageAlt = ComponentAttributeHelper::extractString($attributes, 'image-alt');
}
public function getRootNode(): Node
{
$div = new ElementNode('div');
// Build CSS classes
$classes = ['card', "card--{$this->variant}"];
$div->setAttribute('class', implode(' ', $classes));
// Build CSS classes using Helper
$additionalClasses = [];
if (isset($this->attributes['class']) && is_string($this->attributes['class'])) {
$additionalClasses[] = $this->attributes['class'];
}
$classes = ComponentClassBuilder::build('card', $this->variant, null, $additionalClasses);
$div->setAttribute('class', $classes);
// Apply additional attributes
$filteredAttributes = ComponentAttributeHelper::filterSpecialAttributes(
$this->attributes,
['title', 'subtitle', 'footer', 'image-src', 'image-alt']
);
foreach ($filteredAttributes as $key => $value) {
$div->setAttribute($key, (string)$value);
}
// Build complex nested content as HTML string
$contentHtml = $this->buildContent();
@@ -80,7 +98,14 @@ final readonly class Card implements StaticComponent
}
// Body
$elements[] = '<div class="card__body">' . htmlspecialchars($this->bodyContent) . '</div>';
// Content may already be HTML (from processed placeholders), so check before escaping
if ($this->isHtmlContent($this->bodyContent)) {
// Content is already HTML - output directly
$elements[] = '<div class="card__body">' . $this->bodyContent . '</div>';
} else {
// Content is plain text - escape it
$elements[] = '<div class="card__body">' . htmlspecialchars($this->bodyContent) . '</div>';
}
// Footer
if ($this->footer !== null) {
@@ -90,6 +115,36 @@ final readonly class Card implements StaticComponent
return implode('', $elements);
}
/**
* Check if content contains HTML tags (is already HTML)
* Uses a simple and fast check to avoid performance issues
*/
private function isHtmlContent(string $content): bool
{
// Trim whitespace to avoid false positives
$trimmed = trim($content);
// Empty content is not HTML
if (empty($trimmed)) {
return false;
}
// Simple check: if content starts with < and contains >, it's likely HTML
// This is much faster than regex and avoids performance issues
if (str_starts_with($trimmed, '<') && str_contains($trimmed, '>')) {
// Additional check: ensure it's not just a single character or escaped text
// Look for common HTML tags (table, div, span, etc.)
$commonTags = ['<table', '<div', '<span', '<p', '<h', '<ul', '<ol', '<li', '<a', '<button'];
foreach ($commonTags as $tag) {
if (stripos($trimmed, $tag) !== false) {
return true;
}
}
}
return false;
}
// Factory methods for programmatic usage
public static function create(string $bodyContent): self
{