Solved

CGI ENCODER

Posted on 1999-01-13
5
319 Views
Last Modified: 2013-12-25
Greetings,

I am writing a Unix program which submits some data using the HTTP protocol to a remote CGI script...
I am in need of a C function which will encode a given string (so a CGI program can read it), but I am not sure exactly what should be encoded (i.e. I know all spaces become "+" and fields separated by "&", but don't which characters become hex encoded etc.)
Can anyone provide a C function to Encode a given string?

Thanks.
0
Comment
Question by:idek1
  • 2
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
jconde earned 80 total points
Comment Utility
The encoding in hexadecimal base.

You must do a for from 0 to strlen(your_string) and if your_string[i] is not numeric, or alphanumeric, you must get the number value of the character, convert it to hex base, and add a % before it.

Example:

this+is+\a\+test

the value for \ is 92, so you need to convert 92 to hex base (5C) and add a % before...

encoded string:

this+is+%5Ca%5C+test

..make any sense??

If you need the code please let me know so I can search my C files!

Regards,

Jorge

0
 

Author Comment

by:idek1
Comment Utility
Well yes, however, I suspect that the "." (dot) is not encoded and my question is really about what IS and what is NOT encoded using HTTP. Using your algorithm, the "." would be encoded as hex string, because it is neither a character nor a digit, where it really should not be encoded.

idek1
0
 
LVL 7

Expert Comment

by:jconde
Comment Utility
That depends!!

I have seen browsers that encode everything, and some that don't.

Let me check the algorithms I have (some written by me, some downloaded) and I'll send them to you ok?

--jorge
0
 

Author Comment

by:idek1
Comment Utility

ok... my email is:
irvingd@bigfoot.com

Thanks for your help,
Idek1
0
 
LVL 8

Expert Comment

by:jhurst
Comment Utility
As has been said you can encode more than you need.  The ones that need to be encloded are defined in the http protocol specification.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now