bugranger - Bugs: bug #43738, bug in rifle: only lower case file...

 
 

bug #43738: bug in rifle: only lower case file extentions can be matched by an ext in rifle.conf

Submitted by:  C <mekanofox>
Submitted on:  Tue 02 Dec 2014 12:50:51 PM UTC  
 
Severity:  3 - Normal Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 02 Dec 2014 12:50:51 PM UTC, original submission:  

I believe there is a bug in rifle, on line 198.
The 'lower()' conversion should be left out, i.e. as in the diff below:

198c198
<             extension = os.path.basename(files[0]).rsplit('.', 1)[-1].lower()
---
>             extension = os.path.basename(files[0]).rsplit('.', 1)[-1]

(or, if you prefer it in patch format:

--- rifle.old   2014-03-17 21:51:55.000000000 +0000
+++ rifle.new   2014-11-07 07:52:13.751158088 +0000
@@ -195,7 +195,7 @@
         argument = rule[1] if len(rule) > 1 else ''

         if function == 'ext':
-            extension = os.path.basename(files[0]).rsplit('.', 1)[-1].lower()
+            extension = os.path.basename(files[0]).rsplit('.', 1)[-1]
             return bool(re.search('^(' + argument + ')$', extension))
         elif function == 'name':
             return bool(re.search(argument, os.path.basename(files[0])))

)

The 'extension' variable seems to hold the actual file extension that will be checked against the list of regexes specified after the 'ext' keyword in the 'rifle.conf'. If the regex extension matches, the given command action is executed. For example:

ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz,  has als     = als -- "$@" | "$PAGER"

As it is now, the bug does not allow rifle to act on extensions/regexes containing any upper case letters since the 'extension' var will always be lowercase. For example, something like 'archive.tar.Z' cannot be simply matched by adding to the above list of regex alternatives just 'Z'. (yes, it will match if you add a single lowercase 'z', but that's not really the same extension).

C <mekanofox>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #32583:  rifle.patch added by mekanofox (535B - text/x-patch - just the patch file)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mekanofox (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-12-02 mekanofox Attached File- => Added rifle.patch, #32583

    Back to the top


    Powered by Savane 3.5