Forum Discussion
switch -glob behaviour when comparison string starts with a hyphen
I'm attempting to use this iRule... https://devcentral.f5.com/articles/stop-those-xss-cookie-bandits-irule-style
However, when the server sends "Set-Cookie=SOMETHING=-1" I get the error... bad option "-1": must be -exact, -glob, -regexp, or -- while executing "switch -glob "${testvalue}" { ";secure" - "; secure" { } default { set value "$value; Secure"; } }" ("foreach" body line 8) invoked from within "foreach cookie [HTTP::cookie names] { if { [HTTP::cookie path $cookie] != "/" } { set value [HTTP::cookie value $cookie]; if { "" != $..."
How do I tell "switch" not to interpret the sting "-1" as an option? As you can see in the error message, I've tried enclosing it in quotes.
I can't reproduce this behaviour using tclsh. Is this a bug?
1 Reply
- Kevin_Stewart
Employee
Have you by chance tried the "--" option?
switch -glob -- $testvalue { ... }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com