]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Be more flexible about parsing parameters
authorAlan T. DeKok <aland@freeradius.org>
Wed, 10 Sep 2014 12:26:57 +0000 (08:26 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 10 Sep 2014 12:26:57 +0000 (08:26 -0400)
src/modules/rlm_perl/rlm_perl.c

index b4ec96af63be86875c490a65608f1638d73cbb2d..d42352441a363d6c73f91fc42014699f21915801 100644 (file)
@@ -340,11 +340,30 @@ static ssize_t perl_xlat(void *instance, REQUEST *request, char const *fmt, char
 
                PUSHMARK(SP);
 
-               p = fmt;
-               while ((q = strchr(p, ' '))) {
-                       XPUSHs(sv_2mortal(newSVpvn(p, p - q)));
+               p = q = fmt;
+               while (*p == ' ') {
+                       p++;
+                       q++;
+               }
+               while (*q) {
+                       if (*q == ' ') {
+                               XPUSHs(sv_2mortal(newSVpvn(p, q - p)));
+                               p = q + 1;
+
+                               /*
+                                *      Don't use an empty string
+                                */
+                               while (*p == ' ') p++;
+                               q = p;
+                       }
+                       q++;
+               }
 
-                       p = q + 1;
+               /*
+                *      And the last bit.
+                */
+               if (*p) {
+                       XPUSHs(sv_2mortal(newSVpvn(p, strlen(p))));
                }
 
                PUTBACK;