[gparted] Update list of prohibited fat label characters (#787202)



commit c3ad49d9daafa7cab335ca069875a057c67c1761
Author: Pali Rohár <pali rohar gmail com>
Date:   Sun Sep 3 08:46:59 2017 +0200

    Update list of prohibited fat label characters (#787202)
    
    Add double quote (") to the list of prohibited FAT label characters,
    previously missed [1][2].
    
    Also add single quote (') because mlabel encoded it in a way that both
    Windows and blkid don't understand, although mlabel can correctly decode
    it itself.
    
        # export MTOOLS_SKIP_CHECK=1
        # mlabel ::"MIKE'S" -i /dev/sdf1
        # mlabel -s :: -i /dev/sdf1
         Volume label is MIKE'S (abbr=MIKE_S~1???)
        # blkid -o value -s LABEL /dev/sdf1
        MIKE_S~1???
    
        (8-bit characters in the above output have been replaced with
        question marks (?) just to keep this commit message as 7-bit ASCII).
    
    Finally exclude ASCII control characters below SPACE (0x00 to 0x1F) as
    they also cause mlabel to ask a question and wait for input in the same
    way that prohibited characters do.  As discussed in the previous commit
    [1] the only way to stop GParted waiting forever is to manually kill
    mlabel with signal 9 (KILL).
    
        # mlabel ::"^A" -i /dev/sdf1
        Long file name "^A" contains illegal character(s).
        a)utorename A)utorename-all r)ename R)ename-all
        s)kip S)kip-all q)uit (aArRsSq):
    
    [1] 584137b32b4deed2c20022628baaee6b38570fa5
        Remove prohibited characters from FAT16/32 labels (#755608)
    
    [2] Microsoft TechNet: Label
        https://technet.microsoft.com/en-us/library/bb490925.aspx
    
    Bug 787202 - Update list of prohibited fat label characters

 src/fat16.cc |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/fat16.cc b/src/fat16.cc
index 6e254db..1987192 100644
--- a/src/fat16.cc
+++ b/src/fat16.cc
@@ -265,9 +265,15 @@ const Glib::ustring fat16::sanitize_label( const Glib::ustring &label ) const
        //     https://technet.microsoft.com/en-us/library/bb490925.aspx
        // [2] Replicated in Wikikedia: label (command)
        //     https://en.wikipedia.org/wiki/Label_%28command%29
-       Glib::ustring prohibited_chars( "*?.,;:/\\|+=<>[]" );
+       // Also exclude:
+       // * Single quote (') because it is encoded by mlabel but not understood by
+       //   Windows;
+       // * ASCII control characters below SPACE because mlabel requests input in the
+       //   same way it does for prohibited characters causing GParted to wait forever.
+       Glib::ustring prohibited_chars( "*?.,;:/\\|+=<>[]\"'" );
        for ( unsigned int i = 0 ; i < uppercase_label.size() ; i ++ )
-               if ( prohibited_chars.find( uppercase_label[i] ) == Glib::ustring::npos )
+               if ( prohibited_chars.find( uppercase_label[i] ) == Glib::ustring::npos &&
+                    uppercase_label[i] >= ' '                                             )
                        new_label.push_back( uppercase_label[i] );
 
        // Pad with spaces to prevent mlabel writing corrupted labels.  See bug #700228.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]