Right, I’ve managed to get a bit further into tracking down the bug. It’s definitely because
The problem is probably with libmagic, which apparently cannot recognise CSS. BTW: `
I then tried to make the file look a bit more “CSS-like” by adding an `
JavaScript, on the other hand, is recognised correctly:
This is, of course, unsatisfactory and breaks part of the website app’s functionality.
What could be done to ensure that CSS is recognised correctly and entered into the table?
finfo() doesn’t identify CSS files as such (text/css), but always as text/plain. I’ve tested this on my local machine and on both servers:<?php
$datei = 'shtml01.css';
if (!file_exists($datei)) {
echo "Fehler: Die Datei '$datei' wurde nicht gefunden.";
exit;
}
try {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
if ($finfo === false) {
throw new Exception("Konnte finfo nicht initialisieren.");
}
$mime_type = finfo_file($finfo, $datei);
finfo_close($finfo);
if ($mime_type !== false && $mime_type !== "") {
echo "Der MIME-Typ von '$datei' ist: " . $mime_type;
} else {
echo "Konnte den MIME-Typ für '$datei' nicht bestimmen.";
}
} catch (Exception $e) {
echo "Ein Fehler ist aufgetreten: " . $e->getMessage();
}
?>In the hex editor, the file starts with ‘68 31 20 7B’, which corresponds exactly to ‘h1 {’. Nevertheless, it is identified as text/plain.The problem is probably with libmagic, which apparently cannot recognise CSS. BTW: `
file --mime-type shtml01.css` also returns `text/plain`. `file` also relies on libmagic.I then tried to make the file look a bit more “CSS-like” by adding an `
@import` statement right at the start. Even with that, the file was not recognised as `text/css`.JavaScript, on the other hand, is recognised correctly:
application/javascriptThis is, of course, unsatisfactory and breaks part of the website app’s functionality.
What could be done to ensure that CSS is recognised correctly and entered into the table?
:grinning_squinting_face: