Skip to content

Commit

Permalink
[mms] Merge from upstream - handle keywords/dimensions case-insensiti…
Browse files Browse the repository at this point in the history
…vely.
  • Loading branch information
slusarz committed Oct 24, 2013
1 parent e101c18 commit 605dc43
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
28 changes: 16 additions & 12 deletions framework/Css_Parser/lib/Sabberworm/CSS/Parser.php
Expand Up @@ -43,16 +43,6 @@ public function __construct($sText, Settings $oParserSettings = null) {
}
$this->oParserSettings = $oParserSettings;
$this->blockRules = explode('/', AtRule::BLOCK_RULES);

foreach (explode('/', Size::ABSOLUTE_SIZE_UNITS.'/'.Size::RELATIVE_SIZE_UNITS.'/'.Size::NON_SIZE_UNITS) as $val) {
$size = strlen($val);
if (isset($this->sizeUnits[$size])) {
$this->sizeUnits[$size][] = $val;
} else {
$this->sizeUnits[$size] = array($val);
}
}
ksort($this->sizeUnits, SORT_NUMERIC);
}

public function setCharset($sCharset) {
Expand All @@ -66,6 +56,19 @@ public function getCharset() {

public function parse() {
$this->setCharset($this->oParserSettings->sDefaultCharset);

$this->sizeUnits = array();
foreach (explode('/', Size::ABSOLUTE_SIZE_UNITS.'/'.Size::RELATIVE_SIZE_UNITS.'/'.Size::NON_SIZE_UNITS) as $val) {
$val = $this->strtolower($val);
$size = strlen($val);
if (isset($this->sizeUnits[$size])) {
$this->sizeUnits[$size][] = $val;
} else {
$this->sizeUnits[$size] = array($val);
}
}
ksort($this->sizeUnits, SORT_NUMERIC);

$oResult = new Document();
$this->parseDocument($oResult);
return $oResult;
Expand Down Expand Up @@ -409,8 +412,9 @@ private function parseNumericValue($bForColor = false) {

$sUnit = null;
foreach ($this->sizeUnits as $len => $val) {
if (($pos = array_search($this->peek($len), $val)) !== false) {
$sUnit = $val[$pos];
$peek = $this->peek($len);
if (array_search($this->strtolower($peek), $val) !== false) {
$sUnit = $peek;
$this->consume($len);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions framework/Css_Parser/package.xml
Expand Up @@ -21,7 +21,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Merge from upstream - handle keywords/dimensions case-insensitively.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -188,7 +188,7 @@
<date>2013-10-15</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Merge from upstream - handle keywords/dimensions case-insensitively.
</notes>
</release>
</changelog>
Expand Down

0 comments on commit 605dc43

Please sign in to comment.