Skip to content

Commit ae688a2

Browse files
committed
Bug-fix.
Changelog excerpt: - Some browsers, in some contexts, were raising errors during request inspection concerning the absence of any X-Content-Type-Options header declaration (though it isn't entirely clear whether this error had any actual effect); Fixed.
1 parent e37f491 commit ae688a2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
198198

199199
#### Bugs fixed.
200200
- [2025.07.07]: The formatFilesize method wasn't accounting for negative numbers; Fixed.
201+
- [2025.07.26]: Some browsers, in some contexts, were raising errors during request inspection concerning the absence of any X-Content-Type-Options header declaration (though it isn't entirely clear whether this error had any actual effect); Fixed.
201202

202203
#### Other changes.
203204
- [2025.07.05]: Aesthetic patch.

src/FrontEnd.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Front-end handler (last modified: 2025.07.07).
11+
* This file: Front-end handler (last modified: 2025.07.26).
1212
*/
1313

1414
namespace phpMussel\FrontEnd;
@@ -1588,6 +1588,7 @@ private function eTaggable(string $Asset, ?callable $Callback = null): void
15881588
$ThisAsset = $this->getAssetPath($Asset, true);
15891589
if (strlen($ThisAsset) && is_readable($ThisAsset) && ($ThisAssetDel = strrpos($ThisAsset, '.')) !== false) {
15901590
$Success = false;
1591+
$NoSniff = false;
15911592
$Type = strtolower(substr($ThisAsset, $ThisAssetDel + 1));
15921593
if ($Type === 'jpeg') {
15931594
$Type = 'jpg';
@@ -1601,9 +1602,11 @@ private function eTaggable(string $Asset, ?callable $Callback = null): void
16011602
} elseif ($Type === 'js') {
16021603
$MimeType = 'Content-Type: text/javascript';
16031604
$Success = true;
1605+
$NoSniff = true;
16041606
} elseif ($Type === 'css') {
16051607
$MimeType = 'Content-Type: text/css';
16061608
$Success = true;
1609+
$NoSniff = true;
16071610
}
16081611
if ($Success) {
16091612
$AssetData = $this->Loader->readFile($ThisAsset);
@@ -1619,6 +1622,9 @@ private function eTaggable(string $Asset, ?callable $Callback = null): void
16191622
die;
16201623
}
16211624
header($MimeType);
1625+
if ($NoSniff) {
1626+
header('X-Content-Type-Options: nosniff');
1627+
}
16221628
if (is_callable($Callback)) {
16231629
$AssetData = $Callback($AssetData);
16241630
}

0 commit comments

Comments
 (0)