From: <var...@us...> - 2009-06-25 12:58:09
|
Revision: 6960 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6960&view=rev Author: vargenau Date: 2009-06-25 12:47:08 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Check length of hex color Modified Paths: -------------- trunk/lib/InlineParser.php Modified: trunk/lib/InlineParser.php =================================================================== --- trunk/lib/InlineParser.php 2009-06-25 11:56:16 UTC (rev 6959) +++ trunk/lib/InlineParser.php 2009-06-25 12:47:08 UTC (rev 6960) @@ -856,13 +856,12 @@ function markup ($match, $body) { $color = strtolower(substr($match, 7, -1)); - if (strlen($color) != 7 - and in_array($color, array('red', 'blue', 'gray', 'yellow', 'green', 'cyan', 'black'))) - { // must be a valid color name + + if (in_array($color, array('red', 'blue', 'gray', 'yellow', 'green', 'cyan', 'black')) + or ((substr($color,0,1) == '#') + and ((strlen($color) == 4) or (strlen($color) == 7)) + and (strspn(substr($color,1),'0123456789abcdef') == strlen($color)-1))) { return new HtmlElement('span', array('style' => "color: $color"), $body); - } elseif ((substr($color,0,1) == '#') - and (strspn(substr($color,1),'0123456789abcdef') == strlen($color)-1)) { - return new HtmlElement('span', array('style' => "color: $color"), $body); } else { return new HtmlElement('span', array('class' => 'error'), sprintf(_("unknown color %s ignored"), substr($match, 7, -1))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |