[GRASS-SVN] r29615 - grass/branches/releasebranch_6_3/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jan 8 08:46:14 EST 2008


Author: neteler
Date: 2008-01-08 08:46:14 -0500 (Tue, 08 Jan 2008)
New Revision: 29615

Modified:
   grass/branches/releasebranch_6_3/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. (merge from HEAD)

Modified: grass/branches/releasebranch_6_3/lib/vector/Vlib/legal_vname.c
===================================================================
--- grass/branches/releasebranch_6_3/lib/vector/Vlib/legal_vname.c	2008-01-08 13:44:30 UTC (rev 29614)
+++ grass/branches/releasebranch_6_3/lib/vector/Vlib/legal_vname.c	2008-01-08 13:46:14 UTC (rev 29615)
@@ -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