[GRASS-SVN] r29570 - grass/trunk/lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jan 5 08:21:38 EST 2008
Author: martinl
Date: 2008-01-05 08:21:38 -0500 (Sat, 05 Jan 2008)
New Revision: 29570
Modified:
grass/trunk/lib/vector/Vlib/legal_vname.c
Log:
GForge/520: SQL parser error if output name is 'and', 'or' or 'not'. Check only for and/or/not.
Modified: grass/trunk/lib/vector/Vlib/legal_vname.c
===================================================================
--- grass/trunk/lib/vector/Vlib/legal_vname.c 2008-01-05 12:11:13 UTC (rev 29569)
+++ grass/trunk/lib/vector/Vlib/legal_vname.c 2008-01-05 13:21:38 UTC (rev 29570)
@@ -19,14 +19,17 @@
/*!
\fn int Vect_legal_filename (char *s)
+
\brief Check if output is legal vector name.
Rule: [A-Za-z][A-Za-z0-9_@]*
- \param[in] s filename to be checked
+ Check also for SQL keywords.
- \return 1 OK
- \return -1 if name does not start with letter A..Za..z or if name does not continue with A..Za..z0..9_@
+ \param[in] s filename to be checked
+
+ \return 1 OK
+ \return -1 if name does not start with letter A..Za..z or if name does not continue with A..Za..z0..9_@
*/
int Vect_legal_filename (char *s)
@@ -47,11 +50,22 @@
}
for (s++ ; *s; s++)
- if (! ((*s >= 'A' && *s <= 'Z') || (*s >= 'a' && *s <= 'z') || (*s >= '0' && *s <= '9') || *s == '_' || *s == '@' ) ) {
+ if (! ((*s >= 'A' && *s <= 'Z') || (*s >= 'a' && *s <= 'z') ||
+ (*s >= '0' && *s <= '9') || *s == '_' || *s == '@' ) ) {
G_warning (_("Illegal vector map name <%s>. Character '%c' not allowed."), buf, *s);
return -1;
}
+ /* full list of SQL keywords available at
+ http://www.postgresql.org/docs/8.2/static/sql-keywords-appendix.html
+ */
+ if (G_strcasecmp(buf, "and") == 0 ||
+ G_strcasecmp(buf, "or") == 0 ||
+ G_strcasecmp(buf, "not") == 0) {
+ G_warning (_("Illegal vector map name <%s>. SQL keyword cannot be used as vector map name."), buf);
+ return -1;
+ }
+
return 1;
}
More information about the grass-commit
mailing list