iPXE discussion forum
How to POST / GET params with '+' char inside ? - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: How to POST / GET params with '+' char inside ? (/showthread.php?tid=21802)



How to POST / GET params with '+' char inside ? - alhyene - 2020-02-11 15:36

Hi, first sorry for the previous twice posting which were not working, may because the forum seem to be a little down at that times.

I'm trying to store some parameters on webserver which I can retrieve later in a script form, but can't get the '+' sign to be send / retrieve.

#!ipxe
set data_1:string some+thing
set data_2:uristring some+thing
params --name mydata
param --params mydata data_1 ${data_1}
param --params mydata data_2 ${data_2}
imgfetch http://webserver/conf.php##params=mydata || echo can't POST
//imgfetch http://webserver/conf.php?data_1=some+thing || echo can't GET

conf.php file from webserver :

<?php
$myfile = fopen("/var/www/html/mydata", "wb") or die("Unable to open file!");
fwrite($myfile, "#!ipxe\n");

//foreach ($_GET as $key => $value){
foreach ($_POST as $key => $value){
$txt = "set " . $key . "\t" . $value . "\n";
fwrite($myfile, $txt);
}
fclose($myfile);
?>

result of mydata file :

#!ipxe
set data_1 some thing
set data_2 some thing

I need this for URL like :

https://cloudfront.debian.net/cdimage/unofficial/non-free/cd-including-firmware/10.3.0-live+nonfree/amd64/iso-hybrid/debian-live-10.3.0-amd64-cinnamon+nonfree.iso

Any ideas ?


RE: How to POST / GET params with '+' char inside ? - myxal - 2020-02-13 10:21

Don't know the exact answer, but I think this approach should work. The hex value for ASCII "+" is 2B.

As noted there, if it doesn't work, echo the URL in iPXE.


RE: How to POST / GET params with '+' char inside ? - alhyene - 2020-02-15 22:01

thx for reply, I tried it.

set plus:hex 2b
set plus ${plus:string}
set myURL some${plus}thing

params --name mydata
param --params mydata data_1 ${myURL}
etc...

unfortunaly don't work.

Is this "bug" come from iPXE or webserver / php5 side ?

but if I try :

params --name mydata
param --params mydata data_1 some${plus}thing
etc...

I got : some_thing
and not : some+thing

params --name mydata
param --params mydata data_1 some+thing
etc...

the same (some_thing)

Huh


RE: How to POST / GET params with '+' char inside ? - myxal - 2020-02-17 00:33

Did you try echoing ${myURL}? Perhaps I misunderstood the problem - if it's the params features causing the issue, perhaps you can use standard URL encoding, and request some%2Bthing instead of some+thing?


RE: How to POST / GET params with '+' char inside ? - alhyene - 2020-02-18 14:47

Hi, yes I tried substitute with %2B like :

param --mydata data_1 some%2Bthing , with no luck...

I tried both POST & GET methods with same results.
I tried GET method by the browser and work as expected, eg :
http://127.0.0.1/conf.php?data=some%2Bthing

mydata file : some+thing

Then I think it's an iPXE issue.

But I made an ugly and dirty hack to make it works by using base64 encoding, eg :

#!ipxe
set data_1:string some+thing
set data_2.....
params --name mydata
param --params mydata data_1 ${data_1:base64}
param --params mydata data_2.....
imgfetch http://webserver/conf.php##params=mydata || echo can't POST

conf.php file from webserver :

<?php
$myfile = fopen("/var/www/html/mydata", "wb") or die("Unable to open file!");
fwrite($myfile, "#!ipxe\n");

foreach ($_POST as $key => $value){
$txt = "set " . $key . "\t" . base64_decode($value) . "\n";
fwrite($myfile, $txt);
}
fclose($myfile);
?>

result of mydata file :

#!ipxe
set data_1 some+thing
set data_2.....

Dodgy