Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 13bf741

Browse files
authored
Merge pull request #52 from shinsenter/develop
Fixed CVE-2019-18888
2 parents 4de725e + b2105fd commit 13bf741

File tree

7 files changed

+97
-276
lines changed

7 files changed

+97
-276
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"require":
6565
{
6666
"php": ">=5.6",
67-
"symfony/http-foundation": ">2.6"
67+
"symfony/polyfill-mbstring": "^1.0.0"
6868
},
6969
"minimum-stability": "dev",
7070
"prefer-stable": true,

composer.lock

Lines changed: 7 additions & 238 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Defer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ protected function nodefer()
209209
{
210210
$no_libxml = !$this->native_libxml;
211211
$request = $this->http->request();
212-
$has_nodefer = $request ? (bool) $request->get($this->no_defer_parameter) : false;
212+
$has_nodefer = $request
213+
? (bool) $request->get($this->no_defer_parameter)
214+
: !empty($_REQUEST[$this->no_defer_parameter]);
213215

214216
return $has_nodefer || $no_libxml;
215217
}

src/DeferInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace shinsenter;
1515

1616
if (!defined('DEFER_JS_ROOT')) {
17-
define('DEFER_JS_ROOT', dirname(dirname(__FILE__)));
17+
define('DEFER_JS_ROOT', dirname(__DIR__));
1818
}
1919

2020
if (!defined('DEFER_JS_VERSION')) {
@@ -189,7 +189,7 @@ abstract class DeferInterface
189189
const IMG_XPATH = '//*[(' . DEFER_IMG_TAGS . ') and ' . DEFER_IMG_IGNORE . ']';
190190
const IFRAME_XPATH = '//*[(' . DEFER_IFRAME_TAGS . ') and ' . DEFER_IFRAME_IGNORE . ']';
191191
const BACKGROUND_XPATH = '//*[' . DEFER_JS_IGNORE . ' and @style and contains(@style,"url")]';
192-
const NORMALIZE_XPATH = '//text()[' . DEFER_MINIFY_HTML_IGNORE . ' and not(.=normalize-space(.))]';
192+
const NORMALIZE_XPATH = '//text()[not(.=normalize-space(.))]';
193193

194194
// Variable holders
195195
public static $deferjs_script = null;

src/DeferOptimizer.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ protected function optimize()
4949

5050
// Meta optimizations
5151
$this->addMissingMeta();
52-
$this->addFingerprint();
5352

5453
// Add custom splash screen
5554
$this->addCustomSplashScreen();
5655

5756
// Minify
5857
$this->minifyOutputHTML();
58+
59+
// Footer
60+
$this->addFingerprint();
5961
}
6062

6163
/*
@@ -482,7 +484,7 @@ protected function optimizeStyleTags()
482484

483485
// Update the node content
484486
if ($node->nodeValue != $code) {
485-
$node->nodeValue = htmlspecialchars($code);
487+
$node->nodeValue = $code;
486488
}
487489

488490
// Defer the style tag if there is background url
@@ -512,7 +514,7 @@ protected function optimizeScriptTags()
512514
$code = $this->minifyInlineScript($node->nodeValue);
513515

514516
if ($node->nodeValue != $code) {
515-
$node->nodeValue = htmlspecialchars($code);
517+
$node->nodeValue = $code;
516518
}
517519
}
518520
}
@@ -830,12 +832,12 @@ protected function getPreloadType($node)
830832
protected function addBackgroundColor($node)
831833
{
832834
if ($this->use_color_placeholder) {
833-
if ($this->use_color_placeholder == 'grey') {
835+
if ($this->use_color_placeholder === 'grey') {
834836
// Light grey placeholder
835-
$placeholder = 'background-color:hsl(0,0%,' . rand(95, 99) . '%);';
837+
$placeholder = 'background-color:hsl(0,0%,' . rand(91, 99) . '%);';
836838
} else {
837839
// Colorful placeholder
838-
$placeholder = 'background-color:hsl(' . rand(1, 360) . ',100%,96%);';
840+
$placeholder = 'background-color:hsl(' . rand(1, 360) . ',30%,96%);';
839841
}
840842

841843
$style = (string) $node->getAttribute(static::ATTR_STYLE);

0 commit comments

Comments
 (0)