summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-06-01 15:51:24 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-06-01 15:51:24 +0200
commitad62dda338917350cb678db86a8436a34d045ac9 (patch)
tree859511a02028b7f80abac8d622728c2dcc11e246
parent3b59cc372b2b34b08041ee9c0096c5ef52334a01 (diff)
downloadedoors-ad62dda338917350cb678db86a8436a34d045ac9.zip
edoors-ad62dda338917350cb678db86a8436a34d045ac9.tar.gz
add_destination: increase wrong path detection
-rw-r--r--src/lib/eiotas_particle.c16
-rw-r--r--tests/particle.c2
2 files changed, 17 insertions, 1 deletions
diff --git a/src/lib/eiotas_particle.c b/src/lib/eiotas_particle.c
index a72d55f..6d3facc 100644
--- a/src/lib/eiotas_particle.c
+++ b/src/lib/eiotas_particle.c
@@ -117,6 +117,8 @@ EAPI void eiotas_particle_destinations_add(Eiotas_Particle *particle, const char
static Eina_Bool add_destination(Eiotas_Particle *particle, const char *dst, int n)
{
+ int i, c;
+ char *tmp;
Eina_Stringshare *s;
if(n==0) {
@@ -132,6 +134,20 @@ static Eina_Bool add_destination(Eiotas_Particle *particle, const char *dst, int
return EINA_FALSE;
}
+ for(tmp=(char*)dst, c=0, i=0; i<n; i++, tmp++) {
+ if(*tmp==EIOTAS_ACTION_SEP) {
+ if(*(tmp-1)==EIOTAS_PATH_SEP) {
+ ERR("ignore destination with '%c%c' ",EIOTAS_PATH_SEP,EIOTAS_ACTION_SEP);
+ return EINA_FALSE;
+ }
+ c++;
+ }
+ }
+ if(c>1) {
+ ERR("ignore destination with more then 1 '%c' ",EIOTAS_ACTION_SEP);
+ return EINA_FALSE;
+ }
+
s = eina_stringshare_add_length(dst,n);
eina_array_push(particle->dsts,s);
DBG("add dst >%s<",s);
diff --git a/tests/particle.c b/tests/particle.c
index b6ba450..402e0c5 100644
--- a/tests/particle.c
+++ b/tests/particle.c
@@ -20,7 +20,7 @@ void test_particle()
eiotas_particle_destinations_add(p0,"dom0/room0/room1/doorx?get,door?get,dom0/room0/door0?get");
eiotas_particle_destinations_add(p0," dom0/room0/room1/doorx?get,door?get , dom0/room0/door0?get ");
eiotas_particle_destinations_add(p0," dom0/room0/room1/doorx?get,door?get, dom0/room0/door0?get ");
- eiotas_particle_destinations_add(p0," /suffix, ?suffix, prefix/ , prefix? , ,, ");
+ eiotas_particle_destinations_add(p0," /suffix, ?suffix, prefix/ , prefix? , ,, very/?wrong , very?wrong?too");
acc = eina_array_accessor_new(p0->dsts);
eina_accessor_data_get(acc,0,&p);