[GRASS-dev] [GRASS GIS] #2447: G_legal_filename: Special characters allowed in filenames

#2447: G_legal_filename: Special characters allowed in filenames
------------------------------+---------------------------------------------
Reporter: hcho | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.1.0
Component: LibGIS | Version: svn-trunk
Keywords: G_legal_filename | Platform: All
      Cpu: All |
------------------------------+---------------------------------------------
Currently, G_legal_filename is not filtering out some special characters
including tab, newline, {, |, }, etc. Also, the description of the
function is incorrect because '_' is a non-alphanumeric character allowed
in filenames. I'm not sure exactly what special characters are really
legal. This function should also check non-printable characters.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2447&gt;
GRASS GIS <http://grass.osgeo.org>

#2447: G_legal_filename: Special characters allowed in filenames
------------------------------+---------------------------------------------
Reporter: hcho | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.1.0
Component: LibGIS | Version: svn-trunk
Keywords: G_legal_filename | Platform: All
      Cpu: All |
------------------------------+---------------------------------------------

Comment(by glynn):

Replying to [ticket:2447 hcho]:
> Currently, G_legal_filename is not filtering out some special characters
including tab, newline, {, |, }, etc.

All control characters, including tab and newline are rejected by
{{{
... *s <= ' '
}}}
source:grass/trunk/lib/gis/legal_name.c#L44

Braces and vertical bar aren't considered invalid.

Which characters are invalid is somewhat arbitrary, although it has to
include those which have a specific meaning to the parser (equals, comma),
to the OS (slash) or within map names (at). Apart from those, space,
single quote, double quote, asterisk, control characters and 8-bit
characters are considered invalid, although there's no fundamental reason
for these (some of these may have been added to avoid issues with code
which used system() and/or popen(), but those functions should have been
been eliminated in GRASS 7).

The set of invalid characters hasn't been updated to include all of those
which are invalid on Windows, specifically backslash, colon, question
mark, less than, greater than, vertical bar (asterisk, double quote and
slash are also invalid but are already rejected). It's unlikely that any
of these are likely to be used in existing data sets, with the possible
exception of colon.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2447#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>