Bug 8023 - Lint error when using Captured tags with "uri" rule
Summary: Lint error when using Captured tags with "uri" rule
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Libraries (show other bugs)
Version: SVN Trunk (Latest Devel Version)
Hardware: PC Linux
: P2 blocker
Target Milestone: 4.0.0
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-11 09:17 UTC by Giovanni Bechis
Modified: 2022-08-11 13:25 UTC (History)
2 users (show)



Attachment Type Modified Status Actions Submitter/CLA Status
Proposed patch patch None Giovanni Bechis [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Giovanni Bechis 2022-08-11 09:17:33 UTC
The following rule gives a lint error with a modern Perl version.

  header        __GB_FROM_ADDR         From:addr =~ /(?<GB_FROM_ADDR>.*)/
  uri           GB_STORAGE_GOOGLE_EMAIL m|^https?://storage\.cloud\.google\.com/.{4,128}\#%{GB_FROM_ADDR}|i

The lint error is:
Aug 11 11:05:22.290 [14234] warn: Unescaped left brace in regex is passed through in regex; marked by <-- HERE in m/(?<!\\\\)\\%\\\\{ <-- HERE GB_FROM_ADDR\\\\}/ at (eval 4260) line 1795.
Comment 1 Giovanni Bechis 2022-08-11 09:19:06 UTC
Created attachment 5789 [details]
Proposed patch

Possible fix for the issue, lint errors are fixed and the rule still works.
Comment 2 Henrik Krohns 2022-08-11 11:02:07 UTC
Atleast test was bad as it didn't catch the warnings, now it should:

Sending        t/regexp_named_capture.t
Transmitting file data .done
Committing transaction...
Committed revision 1903347.

Your fix seems to work, let's test few more versions... head hurts with all the escaping stages..
Comment 3 Henrik Krohns 2022-08-11 11:11:52 UTC
Check \%{} in test:
Committed revision 1903351.

The fix looks ok in 5.14 and 5.32... feel free to commit when happy..
Comment 4 Giovanni Bechis 2022-08-11 13:25:34 UTC
Sending        lib/Mail/SpamAssassin/Plugin/Check.pm
Transmitting file data .done
Committing transaction...
Committed revision 1903359.