Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-12-18 09:43:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2008-12-18 09:43:03 +0300
commit96bad930de846de0b13bc59b65e3e4fed41769e9 (patch)
tree03541bd0f8f989e9414ab9d883aec9f083662e8c
parenta196d283ed4d45d5cfd06b8caecab36e9b43e260 (diff)
Added checks so invalid struct and property identifiers while preprocessing,
Changed curve '3d' property to 'planer' and set to a negative bool.
-rw-r--r--source/blender/makesrna/intern/rna_curve.c6
-rw-r--r--source/blender/makesrna/intern/rna_define.c33
2 files changed, 35 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index c83bafc1c4c..ade01c9f2c2 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -113,9 +113,9 @@ void rna_def_curve(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Taper Object", "Curve object name that defines the taper (width).");
/* Flags */
- prop= RNA_def_property(srna, "3d", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_3D);
- RNA_def_property_ui_text(prop, "3D Curve", "Define curve in three dimensions. Note that in this case fill won't work.");
+ prop= RNA_def_property(srna, "planer", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CU_3D);
+ RNA_def_property_ui_text(prop, "2D Curve", "Define curve in two dimensions only. Note that fill only works when this is enabled.");
prop= RNA_def_property(srna, "front", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FRONT);
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 77093938c55..16acb73193a 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include "MEM_guardedalloc.h"
@@ -165,6 +166,22 @@ static int rna_find_sdna_member(SDNA *sdna, const char *structname, const char *
return 0;
}
+static int rna_validate_identifier(const char *identifier)
+{
+ int a=0;
+
+ if (!isalpha(identifier[0])) {
+ return 0;
+ }
+
+ for(a=1; identifier[a] != '\0'; a++) {
+ if (identifier[a]=='_') continue;
+ if (isalnum(identifier[a])==0) return 0;
+ }
+
+ return 1;
+}
+
/* Blender Data Definition */
BlenderRNA *RNA_create()
@@ -280,7 +297,14 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *
StructRNA *srna, *srnafrom= NULL;
StructDefRNA *ds= NULL, *dsfrom= NULL;
PropertyRNA *prop, *propfrom;
-
+
+ if(DefRNA.preprocess) {
+ if (rna_validate_identifier(identifier) == 0) {
+ fprintf(stderr, "RNA_def_struct: struct identifier \"%s\" is an invalid name\n", identifier);
+ DefRNA.error= 1;
+ }
+ }
+
if(from) {
/* find struct to derive from */
for(srnafrom= brna->structs.first; srnafrom; srnafrom=srnafrom->next)
@@ -500,6 +524,13 @@ PropertyRNA *RNA_def_property(StructRNA *srna, const char *identifier, int type,
PropertyRNA *prop;
if(DefRNA.preprocess) {
+
+ if (rna_validate_identifier(identifier) == 0) {
+ fprintf(stderr, "RNA_def_property: property identifier \"%s\" is an invalid name\n", identifier);
+ DefRNA.error= 1;
+ return NULL;
+ }
+
ds= DefRNA.structs.last;
dp= MEM_callocN(sizeof(PropertyDefRNA), "PropertyDefRNA");
rna_addtail(&ds->properties, dp);