Bug: Error when using urlparameter with space inside
The error happends when including a .PHP script in twiki and passing GET variables with whitespace between those.
Test case
http://twiki.stibo.dk/bin/view/Sandbox/NipTest1?date=04-12-03&time=12:14&alarmnumber=117&init_id=0&teksten=test%20buffer&error=error-no_init&action=Retry
The %20 produces this error:
Bad Request
Your browser sent a request that this server could not understand.
The request line contained invalid characters following the protocol string.
The apache log gives this error:
[Thu Dec 4 09:43:32 2003] null: Argument "neo.ctp.aas.dk" isn't numeric in subroutine entry at /usr/lib/perl/5.6.1/Socket.pm line 286.
I use this from PHP:
$string = ref()."?date=".$date."&time=".$time."&alarmnumber=".$anum."&init_id=".$init."&teksten=".$text."&error=".$error."&action=Retry";
header("location: $string");
I use this from Twiki:
%INCLUDE{http://neo.ctp.aas.dk/~nip/new/alarm/alarm.php?date=%URLPARAM{"date"}%&time=%URLPARAM{"time"}%&alarmnumber=%URLPARAM{"alarmnumber"}%&reason=%URLPARAM{"reason"}%&init_id=%URLPARAM{"init_id"}%&teksten=%URLPARAM{"teksten"}%&error=%URLPARAM{"error"}%&action=%URLPARAM{"action"}%}%
Environment
--
NickyPrecht - 04 Dec 2003
Follow up
This is spec, not a bug. If you use
%URLPARAM{"reason"}% you will get de-escaped spaces. That is, if you want to pass URL parameters to a URL you need to escape them again, as in:
%URLENCODE{"%URLPARAM{"reason"}%"}%
See details in
TWikiVariables
Yep! Sorry about that.
I tried to use URLENCODE on the whole include string in various ways, but without success.
The String:
%INCLUDE{"http://neo.ctp.aas.dk/~nip/new/alarm/alarm.php?date=%URLENCODE{"%URLPARAM{"date"}%"}%&time=%URLENCODE{"%URLPARAM{"time"}%"}%&alarmnumber=%URLENCODE{"%URLPARAM{"alarmnumber"}%"}%&reason=%URLENCODE{"%URLPARAM{"reason"}%"}%&init_id=%URLENCODE{"%URLPARAM{"init_id"}%"}%&teksten=%URLENCODE{"%URLPARAM{"teksten"}%"}%&error=%URLENCODE{"%URLPARAM{"error"}%"}%&action=%URLENCODE{"%URLPARAM{"action"}%"}%"}%
Works!
Fix record