[Xfce4-commits] <thunar:master> Improve the extension selection to not match hidden names.

Nick Schermer noreply at xfce.org
Mon Jul 29 10:18:01 CEST 2013


Updating branch refs/heads/master
         to 54d71ef576e443e204e13d10f99994396a38dbb9 (commit)
       from 821c9b480b7feb625461b5ec1f35e92dcc87e3d9 (commit)

commit 54d71ef576e443e204e13d10f99994396a38dbb9
Author: Nick Schermer <nick at xfce.org>
Date:   Mon Jul 29 10:17:07 2013 +0200

    Improve the extension selection to not match hidden names.

 thunar/thunar-util.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/thunar/thunar-util.c b/thunar/thunar-util.c
index 77a36f9..22ffcce 100644
--- a/thunar/thunar-util.c
+++ b/thunar/thunar-util.c
@@ -119,7 +119,9 @@ thunar_util_str_get_extension (const gchar *filename)
 
   /* check if there is an possible extension part in the name */
   dot = strrchr (filename, '.');
-  if (dot == NULL || dot[1] == '\0')
+  if (dot == NULL
+      || dot == filename
+      || dot[1] == '\0')
     return NULL;
 
   /* skip the . */
@@ -132,7 +134,8 @@ thunar_util_str_get_extension (const gchar *filename)
         {
           /* look for a possible container part (tar, psd, epsf) */
           dot2 = thunar_util_strrchr_offset (filename, dot - 1, '.');
-          if (dot2 != NULL)
+          if (dot2 != NULL
+              && dot2 != filename)
             {
               /* check the 2nd part range, keep it between 2 and 5 chars */
               len = dot - dot2 - 1;
@@ -154,7 +157,9 @@ thunar_util_str_get_extension (const gchar *filename)
           dot2 = thunar_util_strrchr_offset (filename, dot - 1, '.');
           /* the extension before .in could be long. check that it's at least 2 chars */
           len = dot - dot2 - 1;
-          if (dot2 == NULL || len < 2)
+          if (dot2 == NULL
+              || dot2 == filename
+              || len < 2)
             break;
 
           /* continue if another .in was found */


More information about the Xfce4-commits mailing list