Browse code

pv: fix {param.count} transformation broken by previous commit

Daniel-Constantin Mierla authored on 01/06/2021 17:45:16
Showing 1 changed files
... ...
@@ -3203,6 +3203,28 @@ char* tr_parse_paramlist(str* in, trans_t *t)
3203 3203
 		goto unknown;
3204 3204
 	}
3205 3205
 
3206
+	if(t->subtype == TR_PL_COUNT) {
3207
+		if(*p==TR_PARAM_MARKER) {
3208
+			start_pos = ++p;
3209
+			_tr_parse_sparamx(p, p0, tp, spec, ps, in, s, 1);
3210
+			t->params = tp;
3211
+			tp = 0;
3212
+			if (t->params->type != TR_PARAM_SPEC && p - start_pos != 1) {
3213
+				LM_ERR("invalid separator in transformation: "
3214
+						"%.*s\n", in->len, in->s);
3215
+				goto error;
3216
+			}
3217
+			while(*p && (*p==' ' || *p=='\t' || *p=='\n')) p++;
3218
+			if(*p!=TR_RBRACKET) {
3219
+				LM_ERR("invalid name transformation: %.*s!\n",
3220
+						in->len, in->s);
3221
+				goto error;
3222
+			}
3223
+		}
3224
+		goto done;
3225
+	}
3226
+
3227
+	/* now transformations with mandatory parameters */
3206 3228
 	if(*p!=TR_PARAM_MARKER)
3207 3229
 	{
3208 3230
 		LM_ERR("invalid %.*s transformation: %.*s\n",
... ...
@@ -3223,29 +3245,15 @@ char* tr_parse_paramlist(str* in, trans_t *t)
3223 3245
 		while(is_in_str(p, in) && (*p==' ' || *p=='\t' || *p=='\n')) p++;
3224 3246
 	}
3225 3247
 
3226
-	if(t->subtype == TR_PL_COUNT) {
3227
-		if(*p==TR_PARAM_MARKER) {
3228
-			start_pos = ++p;
3229
-			_tr_parse_sparamx(p, p0, tp, spec, ps, in, s, 1);
3230
-			t->params = tp;
3231
-			tp = 0;
3232
-			if (tp->type != TR_PARAM_SPEC && p - start_pos != 1) {
3233
-				LM_ERR("invalid separator in transformation: "
3234
-						"%.*s\n", in->len, in->s);
3235
-				goto error;
3236
-			}
3237
-		}
3238
-	} else {
3239
-		if(*p==TR_PARAM_MARKER) {
3240
-			start_pos = ++p;
3241
-			_tr_parse_sparam(p, p0, tp, spec, ps, in, s);
3242
-			t->params->next = tp;
3243
-			tp = 0;
3244
-			if (p - start_pos != 1) {
3245
-				LM_ERR("invalid separator in transformation: "
3246
-						"%.*s\n", in->len, in->s);
3247
-				goto error;
3248
-			}
3248
+	if(*p==TR_PARAM_MARKER) {
3249
+		start_pos = ++p;
3250
+		_tr_parse_sparam(p, p0, tp, spec, ps, in, s);
3251
+		t->params->next = tp;
3252
+		tp = 0;
3253
+		if (p - start_pos != 1) {
3254
+			LM_ERR("invalid separator in transformation: "
3255
+					"%.*s\n", in->len, in->s);
3256
+			goto error;
3249 3257
 		}
3250 3258
 	}
3251 3259
 
... ...
@@ -3256,6 +3264,7 @@ char* tr_parse_paramlist(str* in, trans_t *t)
3256 3264
 		goto error;
3257 3265
 	}
3258 3266
 
3267
+done:
3259 3268
 	t->name = name;
3260 3269
 	return p;
3261 3270