Bug 63612 - [PATCH] Improved Perl file detection
Summary: [PATCH] Improved Perl file detection
Status: RESOLVED MOVED
Alias: None
Product: shared-mime-info
Classification: Unclassified
Component: freedesktop.org.xml (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: Shared Mime Info group
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-16 17:24 UTC by Salve J. Nilsen
Modified: 2018-10-13 10:41 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch to improve Perl and TAP support. Applies against commit 0c41ac8 (4.70 KB, patch)
2013-04-16 17:24 UTC, Salve J. Nilsen
Details | Splinter Review
Improve Perl detection (3.76 KB, patch)
2013-09-30 08:49 UTC, Bastien Nocera
Details | Splinter Review

Description Salve J. Nilsen 2013-04-16 17:24:05 UTC
Created attachment 78102 [details] [review]
Patch to improve Perl and TAP support. Applies against commit 0c41ac8

Hi!

I've added some rules to improve the support for detecting modern Perl programs, modules and tests, plus simple TAP (Test Anything Protocol) output files.

Git diff attached (can be applied using "git apply perl-magic.patch" in the shared-mime-info git repository root directory).

Hope this is useful! :)


Kind regards,

- Salve J. Nilsen
Comment 1 Bastien Nocera 2013-09-30 08:44:28 UTC
Comment on attachment 78102 [details] [review]
Patch to improve Perl and TAP support. Applies against commit 0c41ac8

Review of attachment 78102 [details] [review]:
-----------------------------------------------------------------

::: freedesktop.org.xml.in
@@ +2826,4 @@
>        <match type="string" value='eval \"exec /usr/local/bin/perl' offset="0"/>
>        <match type="string" value="/bin/perl" offset="1:16"/>
>        <match type="string" value="/bin/env perl" offset="1:16"/>
> +      <match type="string" value="#!perl" offset="0"/>

That exists? I've never seen that before.

@@ +2826,5 @@
>        <match type="string" value='eval \"exec /usr/local/bin/perl' offset="0"/>
>        <match type="string" value="/bin/perl" offset="1:16"/>
>        <match type="string" value="/bin/env perl" offset="1:16"/>
> +      <match type="string" value="#!perl" offset="0"/>
> +      <match type="string" value="package " offset="0:256"/>

This is far too generic, so are most of the ones below.

@@ +2849,5 @@
> +    <glob pattern="*.pod"/><!-- documentation -->
> +    <glob pattern="*.t" weight="10"/><!-- CPAN-style Perl test script -->
> +  </mime-type>
> +  <mime-type type="application/x-tap">
> +    <_comment>Test Anything Protocol output</_comment>

You should separate this in another patch. Given the really generic magic, I'm unlikely to take this though.
Comment 2 Bastien Nocera 2013-09-30 08:49:45 UTC
Created attachment 86830 [details] [review]
Improve Perl detection
Comment 3 Bastien Nocera 2013-09-30 08:52:46 UTC
I've removed the TAP support bits, and removed the too-generic magic. Putting on NEEDINFO until a patch is provided for the rest.

commit a6bdb6a198f8f9fe4153f72e5b4d10e1b5057c3e
Author: Salve J. Nilsen <sjn-bugs.freedesktop.org@pvv.org>
Date:   Tue Apr 16 17:24:00 2013 +0000

    Improve Perl detection
    
    https://bugs.freedesktop.org/show_bug.cgi?id=63612
Comment 4 Dwayne Litzenberger 2018-04-01 02:33:51 UTC
See review commends and new bug 105838
Comment 5 Dwayne Litzenberger 2018-04-01 02:36:10 UTC
Comment on attachment 78102 [details] [review]
Patch to improve Perl and TAP support. Applies against commit 0c41ac8

Review of attachment 78102 [details] [review]:
-----------------------------------------------------------------

::: freedesktop.org.xml.in
@@ +2826,4 @@
>        <match type="string" value='eval \"exec /usr/local/bin/perl' offset="0"/>
>        <match type="string" value="/bin/perl" offset="1:16"/>
>        <match type="string" value="/bin/env perl" offset="1:16"/>
> +      <match type="string" value="#!perl" offset="0"/>

I've seen #!perl on Windows machines.  It's not portable (execve doesn't search PATH), but the ActiveState Perl documentation mentions it for some reason:

https://docs.activestate.com/activeperl/5.26/perl/faq/Windows/ActivePerl-Winfaq4.html#What_s_the_equivalent_of_the_she

@@ +2827,5 @@
>        <match type="string" value="/bin/perl" offset="1:16"/>
>        <match type="string" value="/bin/env perl" offset="1:16"/>
> +      <match type="string" value="#!perl" offset="0"/>
> +      <match type="string" value="package " offset="0:256"/>
> +      <match type="string" value="use strict" offset="0:256"/>

This is also too broad.  It incorrectly matches against ECMAScript's strict-mode syntax, which can look like one of the following lines (including quotes and semicolon):

    "use strict";
    'use strict';

Since this code has already been released, I opened up a separate bug report here:
https://bugs.freedesktop.org/show_bug.cgi?id=105838
Comment 6 GitLab Migration User 2018-10-13 10:41:30 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xdg/shared-mime-info/issues/85.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.