After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 787202 - [PATCH] Update list of prohibited fat label characters
[PATCH] Update list of prohibited fat label characters
Status: RESOLVED FIXED
Product: gparted
Classification: Other
Component: application
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gparted maintainers alias
gparted maintainers alias
Depends on:
Blocks:
 
 
Reported: 2017-09-03 08:13 UTC by Pali
Modified: 2017-10-10 17:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] Update list of prohibited fat label characters (1.11 KB, patch)
2017-09-03 08:13 UTC, Pali
none Details | Review
Update list of prohibited fat label characters (v2) (2.83 KB, patch)
2017-09-06 13:29 UTC, Mike Fleetwood
none Details | Review

Description Pali 2017-09-03 08:13:34 UTC
Created attachment 359012 [details] [review]
[PATCH] Update list of prohibited fat label characters

Command mlabel from mtools does not allow also ' " and \005 characters.
Comment 1 Pali 2017-09-03 08:23:41 UTC
When user executes mlabel with prohibited label character then mlabel asks interactively user how to fix it. But because in GParted there is no terminal window for interaction, mlabel command just hangs forever.

This patch ensure that such situation does not happen.
Comment 2 Mike Fleetwood 2017-09-03 14:47:51 UTC
I'll review this.
Comment 3 Mike Fleetwood 2017-09-03 21:11:04 UTC
Good catch on ".  It is in the list of prohibited characters but missing
from the GParted code.

Why are you rejecting ', it is not in the prohibited list?

Why are you rejecting just \005 when mtools rejects all control
characters?
    # export MTOOLS_SKIP_CHECK=1
    # mlabel ::"" -i /dev/sdb14
    Long file name "" contains illegal character(s).
    a)utorename A)utorename-all r)ename R)ename-all 
    s)kip S)kip-all q)uit (aArRsSq): q
Comment 4 Pali 2017-09-04 06:31:26 UTC
I copied prohibited characters from the mtools source code, vfat.c contains:

const char *short_illegals=";+=[]',\"*\\<>/?:|";
const char *long_illegals = "\"*\\<>/?:|\005";
Comment 5 Mike Fleetwood 2017-09-04 13:13:11 UTC
The commit message should be describing why a change is required, making
it as easily as possible for the reviewer to say yes that's correct and
apply it.  So far justification is weak.  At the moment I am tempted to
only add " because it is a prohibited character the code currently
misses and leave it at that.
Comment 6 Pali 2017-09-04 13:28:41 UTC
mtools in vfat.c contains above list of illegal characters. And " ' \005 are illegal too (specified in list), so gparted should not allow to pass them into mtools. My patch adds those 3 characters into gparted blacklist.
Comment 7 Mike Fleetwood 2017-09-04 17:32:22 UTC
I am after some indication that you didn't just copy those lists of
illegal characters and assume mlabel will reject them.  What happened
when you used mlabel to write a label containing a single quote?
Comment 8 Pali 2017-09-04 22:02:01 UTC
$ mlabel ::"label" -i fat
$ mdir :: -i fat
 Volume in drive : is LABEL

$ mlabel ::'"' -i fat
Long file name """ contains illegal character(s).

$ mlabel ::"'" -i fat
$ mdir :: -i fat
 Volume in drive : is ' (abbr=_~1        )
$ blkid -o value -s LABEL -p fat
_~1

So looks like specifying ' as label is accepted by mlabel, but then label stored in root directory looks like some garbage...

Anyway, in mtools handling of illegals is complicated, also any character which matches "c < ' ' && c != '\005' && !(c & 0x80)" is also illegal.

So all control characters (below space) should be prohibited.

$ mlabel ::`echo -e "\005"` -i fat
Long file name "" contains illegal character(s).

$ mlabel ::`echo -e "\006"` -i fat
Long file name "" contains illegal character(s).
Comment 9 Pali 2017-09-05 11:11:29 UTC
Anyway, better would be to disallow in UI to enter those disallowed characters instead of current solution when label string is filtered prior to passing it into external program.
Comment 10 Mike Fleetwood 2017-09-06 13:29:01 UTC
Created attachment 359267 [details] [review]
Update list of prohibited fat label characters (v2)

(In reply to Pali from comment #9)
> Anyway, better would be to disallow in UI to enter those disallowed
> characters instead of current solution when label string is filtered prior
> to passing it into external program.
Yes only valid characters should be accepted as input.  However there
are different sets of valid characters for different file system labels.
Non-trivial change which needs researching and testing.

Anyway, I am going to commit this change in a day or so unless you see
any issue.  It excludes all ASCII control characters below SPACE and
updates the commit message about why the change is needed.
Comment 11 Pali 2017-09-06 20:53:19 UTC
Patch looks good for me.

> However there are different sets of valid characters for different file system labels.

E.g. in KDE Partition Manager filesystem classes can provide its own validator (e.g. regular expression) which is used by GUI input fields for entering label as constraint what can be entered by user.

I do not know if GTK's input field class supports such constraint, but Qt has it.

So this is just a suggestion for possible implementation.
Comment 12 Mike Fleetwood 2017-09-07 12:27:20 UTC
The following commit has been pushed upstream to the GIT repo ready for
inclusion in the next GParted release.

Update list of prohibited fat label characters (#787202)
https://git.gnome.org/browse/gparted/commit/?id=c3ad49d9daafa7cab335ca069875a057c67c1761
Comment 13 Curtis Gedak 2017-10-10 17:25:03 UTC
This enhancement was included in the GParted 0.30.0 release on October 10, 2017.