LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-24-2011, 11:45 AM   #1
wulfram
LQ Newbie
 
Registered: Jun 2011
Posts: 2

Rep: Reputation: Disabled
Submitting using curl - include html tags


I am writing a script that is used to submit a package to testflight from my build system. In order to make the presentation as clear as possible I would like to include some basic HTML in the note section, however, using a < or > causes an error in curl. I have tried different variations of quoting and escaping but have not yet been able to find the solution.

Code:
VERSION_HEADER='<strong>Version: </strong>'
VERSION=`cat $VERSION_NUMBER_FILE`
NOTES+=( "$VERSION_HEADER$VERSION\n" )
NOTES+=${CHANGESET[@]}

curl -v http://testflightapp.com/api/builds.xml -F file="@$PWD/$FILE_TO_UPLOAD"  -F api_token=$API_TOKEN -F team_token=$TEAM_TOKEN -F notes="`echo ${NOTES[@]}`" -F notify=True -F distribution_lists='Testers'
Using the above I get:
Code:
curl: (26) failed creating formpost data
If I use a \ to escape the < and > then the curl passes but the submission is \< and \> which is not well formatted html.

If I use VERSION_HEADER="'<strong>Version: </strong>'" then the single quotes are submitted.

If I use &lt; or &gt; then those are submitted but the receiving api does not decode them correctly.

Can anyone suggest a way to submit exactly:
<strong>Version: </strong>
 
Old 06-24-2011, 12:34 PM   #2
audriusk
Member
 
Registered: Mar 2011
Location: Klaipėda, Lithuania
Distribution: Slackware
Posts: 360

Rep: Reputation: 199Reputation: 199
You need to URL-encode your data before submitting it. It would look like this (using Python in example):
Code:
>>> import urllib
>>> print urllib.quote('<strong>foo</strong>')
%3Cstrong%3Efoo%3C/strong%3E
curl has --data-urlencode option, although I'm not sure if it can be used like -F.
 
Old 06-24-2011, 12:46 PM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
From the cURL manual:
Code:
  To send a field value literally without interpreting a leading '@'
  or '<', or an embedded ';type=', use --form-string instead of
  -F. This is recommended when the value is obtained from a user or
  some other unpredictable source. Under these circumstances, using
  -F instead of --form-string would allow a user to trick curl into
  uploading a file.
Also, you can use "${NOTES[*]}" instead of "`echo ${NOTES[@]}`".
 
1 members found this post helpful.
Old 06-24-2011, 02:56 PM   #4
wulfram
LQ Newbie
 
Registered: Jun 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks very much. The --form-string works exactly as I need it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
best client side way to include html within html entz Programming 1 09-12-2009 09:56 PM
Curl getting html tags aliahsan81 Programming 8 07-31-2009 09:02 AM
mutt and html tags cizzi Linux - Software 3 03-30-2008 08:21 PM
strip html tags rblampain Programming 6 08-07-2005 06:22 AM
HTML, PHP, forms, submitting data Problem Silent1 Programming 3 08-31-2004 03:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration