Skip to content
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

Fixed security holes as found in #23. #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
{
"name": "Kai Mallea",
"email": "[email protected]"
},
{
"name": "Merula Fideley"
}
],
"require": {
Expand Down
16 changes: 10 additions & 6 deletions src/ChrisKonnertz/BBCode/BBCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BBCode
/**
* The current version number
*/
const VERSION = '1.1.2';
const VERSION = '1.1.3';

/**
* The text with BBCodes
Expand Down Expand Up @@ -286,6 +286,10 @@ protected function generateTag(Tag $tag, &$html, Tag $openingTag = null, array $
{
$code = null;

// secure various unwanted states
$propHasSemicol = str_contains($tag->property, ';');
$propHasQuote = str_contains($tag->property, '"');

if (in_array($tag->name, $this->ignoredTags)) {
return $code;
}
Expand Down Expand Up @@ -328,7 +332,7 @@ protected function generateTag(Tag $tag, &$html, Tag $openingTag = null, array $
break;
case self::TAG_NAME_EMAIL:
if ($tag->opening) {
if ($tag->property) {
if ($tag->property && !$propHasQuote) {
$code = '<a href="mailto:'.$tag->property.'">';
} else {
$code = '<a href="mailto:';
Expand All @@ -343,7 +347,7 @@ protected function generateTag(Tag $tag, &$html, Tag $openingTag = null, array $
break;
case self::TAG_NAME_URL:
if ($tag->opening) {
if ($tag->property) {
if ($tag->property && !$propHasQuote) {
$code = '<a href="'.$tag->property.'">';
} else {
$code = '<a href="';
Expand Down Expand Up @@ -449,7 +453,7 @@ protected function generateTag(Tag $tag, &$html, Tag $openingTag = null, array $
break;
case self::TAG_NAME_FONT:
if ($tag->opening) {
if ($tag->property) {
if ($tag->property && !$propHasSemicol && !$propHasQuote) {
$code = '<span style="font-family: '.$tag->property.'">';
}
} else {
Expand All @@ -458,7 +462,7 @@ protected function generateTag(Tag $tag, &$html, Tag $openingTag = null, array $
break;
case self::TAG_NAME_SIZE:
if ($tag->opening) {
if ($tag->property) {
if ($tag->property && !$propHasSemicol && !$propHasQuote) {
$code = '<span style="font-size: '.$tag->property.'%">';
}
} else {
Expand All @@ -467,7 +471,7 @@ protected function generateTag(Tag $tag, &$html, Tag $openingTag = null, array $
break;
case self::TAG_NAME_COLOR:
if ($tag->opening) {
if ($tag->property) {
if ($tag->property && !$propHasSemicol && !$propHasQuote) {
$code = '<span style="color: '.$tag->property.'">';
}
} else {
Expand Down