Concatenating/inserting strings with backslashes

Brian Candler B.Candler at pobox.com
Fri Nov 9 18:05:10 CET 2012


> try:
> 
> if (%{reply:Reply-Message} =~ /(.*)/) {
>    update reply {
>          Reply-Message = "stuff %{1}"
>    }
> }

Nice idea, but it appears to suffer the same expansion problem.

As you have written it gives this error:

  Bare %{...} is invalid in condition at: %{reply:Reply-Message} =~ /(.*)/)

Adding the double quotes:

update reply {
  Reply-Message := "foo"
}
if ("%{reply:Reply-Message}" =~ /(.*)/) {
  update reply {
    Reply-Message := "%{1}\\\\nbar"    
  }
}  
if ("%{reply:Reply-Message}" =~ /(.*)/) {
  update reply {
    Reply-Message := "%{1}\\\\nbaz"
  }
}

This gives foo <newline> bar <newline> baz

update reply {
  Reply-Message := "foo"
}
if ("%{reply:Reply-Message}" =~ /(.*)/) {
  update reply {
    Reply-Message := "%{1}\\\\\\\\nbar"
  }
}
if ("%{reply:Reply-Message}" =~ /(.*)/) {
  update reply {
    Reply-Message := "%{1}\\\\\\\\nbaz"
  }
}

This gives foo <newline> bar <backslash> <n> baz

Regards,

Brian.


More information about the Freeradius-Users mailing list