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

Commit 550f7a3

Browse files
authored
Merge pull request #50 from shinsenter/develop
Fixed CVE-2019-18888
2 parents ba5d15f + 1dc1b0f commit 550f7a3

File tree

8 files changed

+131
-77
lines changed

8 files changed

+131
-77
lines changed

assets/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,6 @@
223223
window[ADD_EVENT_LISTENER](LOAD_EVENT, deferscript);
224224

225225
defermedia();
226-
// copyright();
226+
copyright();
227227

228228
})(this, document, console, 'defer_helper');

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@
6363
},
6464
"require":
6565
{
66-
"php": ">=5.6",
67-
"symfony/http-foundation": ">2.6"
66+
"php": ">=5.6.20",
67+
"symfony/mime": "<2.8.0||>2.8.50 <3.4.0||>3.4.34 <4.2.0||>4.2.11 <4.3.0||>=4.3.8",
68+
"symfony/http-foundation": ">2.6 <2.8.0||>2.8.50 <3.4.0||>3.4.34 <4.2.0||>4.2.11 <4.3.0||>=4.3.8"
6869
},
6970
"minimum-stability": "dev",
7071
"prefer-stable": true,

composer.lock

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

public/helpers.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)