Bug 416223

Summary: html files are sometimes recognized as application/x-perl based on "use strict" file content
Product: [Applications] dolphin Reporter: Mike L <mykdebugs>
Component: view-engine: details modeAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: normal CC: kde, kfm-devel
Priority: NOR    
Version First Reported In: 18.04.3   
Target Milestone: ---   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Mike L 2020-01-13 22:25:35 UTC
SUMMARY
html files are sometimes recognized as application/x-perl based on "use strict" file content

In the presence of the string "use strict" inside a script tag in an html file, the filetype recognition is flaky.

I recently installed the OS clean and copied over some stuff in .config, .local, and .kde, so that may be a factor.

STEPS TO REPRODUCE
1. open html file (see ADDITIONAL INFORMATION below)
2. make indicated edits
3. view changed filetype in dolphin
4. there are a couple cases I can't repro atm where uncommenting the script tag in the header (or removing it entirely) would switch it one way or the other

OBSERVED RESULT
filetype changes to application/x-perl
icon, properties, and click action change
launching html files from applications (e.g. dropbox) opens them in kate (don't know if that action is using dolphin or if both are using something else)

EXPECTED RESULT
should still be recognized as html

I think kde/ubuntu shouldn't be trying this hard to determine filetype. Command line 'file' command works fine.
Maybe not specific to dolphin?


SOFTWARE/OS VERSIONS
Kernel: 5.0.0-37-generic
Linux/KDE Plasma:
(available in About System)
KDE Plasma Version: 5.12.9
KDE Frameworks Version: 5.44.0
Qt Version: 5.9.5

ADDITIONAL INFORMATION
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Long running task broken up with timers</title>
<!--<script src="../assert.js"></script>-->
</head>
<body>
if you do any of:
ignore this line
ignore this line
remove last four lines of this text OR remove last single line of this text and the title and script tag in the header
then kubuntu thinks this file is application/x-perl
<script>
"use strict";
</script>
</body>
</html>
Comment 1 Kai Uwe Broulik 2020-01-14 08:35:52 UTC
I'd say this is a bug in shared mime info, please report it there: https://gitlab.freedesktop.org/xdg/shared-mime-info/issues