[Bug 1890716] Re: misidentifies .html file as Perl script when it contains JavaScript "use strict"
@Kai Kasurinen >probably fixed on shared-mime-info 2.0: >https://gitlab.freedesktop.org/xdg/shared-mime-info/-/commit/18bb7cfc6c43d710ecf60339b5dd9bd19c297cdf Yeah, well. It's if they only used the same database. -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to shared-mime-info in Ubuntu. https://bugs.launchpad.net/bugs/1890716 Title: misidentifies .html file as Perl script when it contains JavaScript "use strict" To manage notifications about this bug go to: https://bugs.launchpad.net/shared-mime-info/+bug/1890716/+subscriptions -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 1890716] Re: misidentifies .html file as Perl script when it contains JavaScript "use strict"
If you wrap string in the proper tags you will get the same result, but with different offset (28 chars): tee "index.html" < `printf "x"%.0s {1..228}` use strict eol # -> text/html -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to shared-mime-info in Ubuntu. https://bugs.launchpad.net/bugs/1890716 Title: misidentifies .html file as Perl script when it contains JavaScript "use strict" To manage notifications about this bug go to: https://bugs.launchpad.net/shared-mime-info/+bug/1890716/+subscriptions -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 1890716] Re: misidentifies .html file as Perl script when it contains JavaScript "use strict"
#INTRO After digging up for a while I've found where the issue comes from for both `.html` and `.py` (bug #1857824) files. #SHORT The culprit responsible for misidentification resides in `.xml` database which specifies how to match mime-type against input data. It can be found here [2]. #LONG The `kmimetypefinder.cpp` pulls up [0] `QMimeDatabase db` apis by `db.mimeTypeForFile(...)` which in turns bootstrup `QMimeDatabasePrivate ...` XML database from .xml file.[1] If we look carefully at the content of the `"text/x-perl"` entry we would see the following: ``` ... ... ``` Did you notice the offset attribute `"0:256"`? Now if we run the following two cases we will see that files whose content contains keywords `use strict` in the range of 1..256 will be identified as `text/x-perl` script and as `text/html` if the `use trict` is located outside of such range otherwise, checkout: 💲 tee "index.html"
[Bug 1890716] Re: misidentifies .html file as Perl script when it contains JavaScript "use strict"
With the same setup I have the `mimetype` to output `text/html` for `index.html`. It seems it workds correctly. -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to shared-mime-info in Ubuntu. https://bugs.launchpad.net/bugs/1890716 Title: misidentifies .html file as Perl script when it contains JavaScript "use strict" To manage notifications about this bug go to: https://bugs.launchpad.net/shared-mime-info/+bug/1890716/+subscriptions -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 1890716] Re: misidentifies .html file as Perl script when it contains JavaScript "use strict"
** Also affects: kde-cli-tools (Ubuntu) Importance: Undecided Status: New -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to shared-mime-info in Ubuntu. https://bugs.launchpad.net/bugs/1890716 Title: misidentifies .html file as Perl script when it contains JavaScript "use strict" To manage notifications about this bug go to: https://bugs.launchpad.net/shared-mime-info/+bug/1890716/+subscriptions -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 1890716] Re: kmimetypefinder5 *.html reports wrong type
I've reported a new bug providing a complete and correct description: https://bugs.launchpad.net/ubuntu/+source/kde-cli-tools/+bug/1896682 This one can be safely closed. -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to shared-mime-info in Ubuntu. https://bugs.launchpad.net/bugs/1890716 Title: kmimetypefinder5 *.html reports wrong type To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/shared-mime-info/+bug/1890716/+subscriptions -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 1890716] Re: kmimetypefinder5 *.html reports wrong type
New bug reopened with complete and correct explanation: https://bugs.launchpad.net/ubuntu/+source/kde-cli-tools/+bug/1896682 ** Changed in: shared-mime-info (Ubuntu) Status: Incomplete => Invalid -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to shared-mime-info in Ubuntu. https://bugs.launchpad.net/bugs/1890716 Title: kmimetypefinder5 *.html reports wrong type To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/shared-mime-info/+bug/1890716/+subscriptions -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 1890716] Re: xdg-mime query filetype index.html reports wrong type
After running that commands I got the following output: $ ... Running kmimetypefinder5 "/home/alex/Desktop/index.html" application/x-perl It seems like that kmimetypefinder5 is major culprit here. I've found another unrelated bugreport here which was reported about a year ago: https://bugs.launchpad.net/ubuntu/+source/kde-cli-tools/+bug/1857824 In that case the program reports wrong type for *.py files with correct content. Weird! I think it's wortht to rename this bugreport. ** Summary changed: - xdg-mime query filetype index.html reports wrong type + kmimetypefinder5 *.html reports wrong type -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to shared-mime-info in Ubuntu. https://bugs.launchpad.net/bugs/1890716 Title: kmimetypefinder5 *.html reports wrong type To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/shared-mime-info/+bug/1890716/+subscriptions -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 1890716] Re: xdg-mime query filetype index.html reports wrong type
I just have tried a fresh new user. The output is identical. See attached screenshot. ** Attachment added: "xdg-mime query wrong result" https://bugs.launchpad.net/ubuntu/+source/shared-mime-info/+bug/1890716/+attachment/5413048/+files/Screenshot_20200921_232318.png -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to shared-mime-info in Ubuntu. https://bugs.launchpad.net/bugs/1890716 Title: xdg-mime query filetype index.html reports wrong type To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/shared-mime-info/+bug/1890716/+subscriptions -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 1890716] Re: xdg-mime query filetype index.html reports wrong type
Hi Sebastien. Thaks your for your reply. I suggest you to do the following to see that even if file is starting with proper tags it is recognized as `application/x-perl`: $ tee "index.html" < use strict eol $ xdg-mime query filetype index.html # -> application/x-perl - wrong type Why did you tagged report as invalid? I just got a file with minified JS code which has `use strict` burrowed deep somewhere inside correct html file but it's still recognized as perl script. I can't use some tools to open the file in browser by using xdg-open and forced to use browser-specific launcher. -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to shared-mime-info in Ubuntu. https://bugs.launchpad.net/bugs/1890716 Title: xdg-mime query filetype index.html reports wrong type To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/shared-mime-info/+bug/1890716/+subscriptions -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 1890716] Re: xdg-mime query filetype index.html reports wrong type
why did you tag the report* Bump. -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to shared-mime-info in Ubuntu. https://bugs.launchpad.net/bugs/1890716 Title: xdg-mime query filetype index.html reports wrong type To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/shared-mime-info/+bug/1890716/+subscriptions -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs