[File] Misidentified python script
Christos Zoulas
christos at zoulas.com
Tue Mar 3 13:45:17 UTC 2020
Committed, thanks!
christos
> On Mar 2, 2020, at 9:01 PM, Steve Grubb <sgrubb at redhat.com> wrote:
>
> Hello,
>
> On Monday, March 2, 2020 10:14:00 AM EST Steve Grubb wrote:
>> I can see how it is matching the from and then import. However, I think the
>> regex is assuming too much. You cannot have a carriage return between from
>> and import and whatever python module you are importing. You get something
>> like this if you do:
>>
>> File "./test.py", line 2
>> import
>> ^
>> SyntaxError: invalid syntax
>>
>> I don't know if anything can be done about this since it is suspiciously
>> close to actual code
>
> After testing all day, the following patch fixes it for me. Bottom line,
> python doesn't tolerate \f\r\n between certain keywords.
>
> Best Regards,
> -Steve
>
>
> diff --git a/magic/Magdir/python b/magic/Magdir/python
> index 39fd3aec..f24e469e 100644
> --- a/magic/Magdir/python
> +++ b/magic/Magdir/python
> @@ -90,7 +90,7 @@
>
> # from module.submodule import func1, func2
> 0 search/8192 import
> ->0 regex \^from[\040\t\f\r\n]+([A-Za-z0-9_]|\\.)+[\040\t\f\r\n]+import.*$ Python script text executable
> +>0 regex \^from[\040\t]+([A-Za-z0-9_]|\\.)+[\040\t]+import.*$ Python script text executable
> !:strength + 15
> !:mime text/x-script.python
>
>
>
>
>
> --
> File mailing list
> File at astron.com
> https://mailman.astron.com/mailman/listinfo/file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <https://mailman.astron.com/pipermail/file/attachments/20200303/e5219867/attachment.asc>
More information about the File
mailing list