colasnahaboo / cgibashopts Goto Github PK
View Code? Open in Web Editor NEWBASH library to parse web forms parameters for bash shell web CGI scripts, even with binary file uploads
License: MIT License
BASH library to parse web forms parameters for bash shell web CGI scripts, even with binary file uploads
License: MIT License
Hi, need to run server to make my canon lbp-810 become wifi-printer, using busybox httpd, for cgi i use bash. found this lib, but when i upload pdf file, everything it have is:
%PDF-1.3
when i upload a txt, it is full (tho it is one line, will try something larger...). when i upload a jpeg, it is printing the blank page, will try to analyze the jpeg is it even have something.
so, why does it truncate the pdf to just header?
thanks
Use GitReports for this:
https://gitreports.com/issue/ColasNahaboo/cgibashopts
And document it in Readme.md and personal wiki page
Hi,
I'm trying to convert a bash script to a CGI. This script takes a file and an text field as inputs.
My form looks like this:
<form method="POST" action="/backend.sh" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="text" name="text" />
<button type="submit">Go</button>
</form>
On the backend I receive the file properly:
FORMFILE_file=/tmp/cgibashopts-files.8/file
FORMS=file
But I don't receive the text value.
If I remove the file input :
<form method="POST" action="/backend.sh" enctype="multipart/form-data">
<input type="text" name="text" />
<button type="submit">Go</button>
</form>
Then I get the text value:
FORMS=text
FORM_text=dqdfsq
FORMFILES=
FORMQUERY=
Is it possible to handle both? Am I using it a wrong way?
[version 4.1.1]
# ./tests/tewiba -v
== Sourcing __INIT__
All tests OK ==
# ./tests/RUN-ALL-TESTS
produce no output
POST http://e.com/cgi-bin/TEST HTTP/1.1
Host: e.com
Connection: Keep-Alive
Content-Type: multipart/form-data, boundary=ahp1bnc4hlafmnvyuay783qlh9k1uv76
Content-Length: 2334
Connection: close
--ahp1bnc4hlafmnvyuay783qlh9k1uv76
Content-Disposition: form-data; name="url"
https://some.url
--ahp1bnc4hlafmnvyuay783qlh9k1uv76
Content-Disposition: form-data; name="auth"
a0b50b5db9d
--ahp1bnc4hlafmnvyuay783qlh9k1uv76
Content-Disposition: form-data; name="method"
POST
--ahp1bnc4hlafmnvyuay783qlh9k1uv76
Content-Disposition: form-data; name="send_content_type"
application/xml
--ahp1bnc4hlafmnvyuay783qlh9k1uv76
Content-Disposition: form-data; name="receive_content_type"
application/xml
--ahp1bnc4hlafmnvyuay783qlh9k1uv76
Content-Disposition: form-data; name="json2xml"
Y
--ahp1bnc4hlafmnvyuay783qlh9k1uv76
Content-Disposition: form-data; name="data"; filename="file.xml"
Content-Type: application/xml
<?xml version="1.0" encoding="UTF-8"?><e...e>
--ahp1bnc4hlafmnvyuay783qlh9k1uv76--
source ./cgibashopts
echo "$FORMS"
will output
ahp1bnc4hlafmnvyuay783qlh9k1uv76ContentDispositionformdataname name name name name name name filename
See #3 (comment)
This is an issue created by another account
[version 4.1.1]
== Sourcing INIT
== Test file: filefield-runaway.test:
== file field then text field
TEST ERROR file field then text field rest of params gobbled: 1,5d0
< Content-Disposition: form-data; name="foo"
<
< bar
< -----------------------------234854398038784223431883737325--
<
***ERRORS:1
== Test file: form-files.test:
== Form file upload from browser CBOgenf-Chromium62linux
== Form file upload from browser CBOgenf-ff57linux
== Form file upload from browser CBOgenf-ff57W10
== Form file upload from browser CBOgenf-GoogleChrome62W10
== Form file upload from browser CBOgenf-MicrosoftEdge40W10
TEST ERROR Form file upload from browser CBOgenf-MicrosoftEdge40W10 file 5 differ for browser CBOgenf-MicrosoftEdge40W10. See difference from expected to result by: diff /d02/cgi-bin/tests/files-dos2/file5 /tmp/CBOgenf-MicrosoftEdge40W10-file5
== Form file upload from browser CBOgenf-WindowsPhoneLumia
TEST ERROR Form file upload from browser CBOgenf-WindowsPhoneLumia file 5 differ for browser CBOgenf-WindowsPhoneLumia. See difference from expected to result by: diff /d02/cgi-bin/tests/files-dos2/file5 /tmp/CBOgenf-WindowsPhoneLumia-file5
***ERRORS:2
== Test file: form-nofiles.test:
== Form file upload from browser CBOgenf-Chromium62linux
== Form file upload from browser CBOgenf-ff57linux
== Form file upload from browser CBOgenf-ff57W10
== Form file upload from browser CBOgenf-GoogleChrome62W10
== Form file upload from browser CBOgenf-MicrosoftEdge40W10
== Form file upload from browser CBOgenf-WindowsPhoneLumia
== OK
== Test file: form.test:
== Form POST submit from browser CBOgen-Chromium62linux
== Form POST submit from browser CBOgen-ff57linux
== Form POST submit from browser CBOgen-ff57W10
== Form POST submit from browser CBOgen-GoogleChrome62W10
== Form POST submit from browser CBOgen-Microsoft
== OK
== Test file: query-string.test:
== Empty querystring
== Indexed search, legacy
== Single param
== Multiple params
== param function
== urldecode
== OK
== ***** Total tests failed: 3 *****
Implement option parsing with getopts, so that we can add more customisations in the future
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.