Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion lib/private/AppFramework/Http/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,32 @@ public function setReadfile($path) {
*/
#[\Override]
public function setHeader($header) {
header($header);
$maxLen = 7800;
if (strlen($header) > $maxLen) {
foreach (['Content-Security-Policy:', 'Feature-Policy:'] as $prefix) {
Comment thread
n-iv marked this conversation as resolved.
Outdated
if (strncmp($header, $prefix, strlen($prefix)) === 0) {
$value = ltrim(substr($header, strlen($prefix)));
$directives = array_filter(array_map('trim', explode(';', $value)));
$segment = '';
$first = true;
foreach ($directives as $directive) {
$candidate = $segment === '' ? $directive : $segment . ';' . $directive;
if (strlen($prefix . ' ' . $candidate . ';') > $maxLen && $segment !== '') {
header($prefix . ' ' . $segment . ';', $first);
$first = false;
$segment = $directive;
} else {
$segment = $candidate;
}
}
if ($segment !== '') {
header($prefix . ' ' . $segment . ';', $first);
}
Comment thread
n-iv marked this conversation as resolved.
Outdated
return;
}
}
}
header($header);
Comment thread
n-iv marked this conversation as resolved.
Outdated
}

Comment thread
n-iv marked this conversation as resolved.
Outdated
/**
Expand Down
Loading