Skip to content

Accessible icons #43

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

Merged
merged 5 commits into from
Sep 9, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make escape string function
  • Loading branch information
natewiebe13 committed Sep 7, 2021
commit 6985e8c9cf349a278d9719048bdb64315d0e7a8a
7 changes: 6 additions & 1 deletion src/Icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function ($final, $current) use ($attributes): string {
$attributeValue = $attributeValue ? 'true' : 'false';
}

$attributeValue = \htmlspecialchars((string)$attributeValue, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', false);
$attributeValue = $this->escapeString((string)$attributeValue);

return \sprintf('%s %s="%s"', $final, $current, $attributeValue);
},
Expand Down Expand Up @@ -63,6 +63,11 @@ function ($item): bool {
);
}

private function escapeString(string $string): string
{
return \htmlspecialchars($string, \ENT_QUOTES | \ENT_SUBSTITUTE, 'UTF-8', false);
}

public function __toString(): string
{
return $this->render();
Expand Down