Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 700
  • Last Modified:

Javascript and control characters

Heya Experts,

(Linux, Apache, Javascript)

I have a form which is being created dynamically. It has couple of fields with 1-10 in size. The form collects the data, verifies it and sends the data (form.field.value)  to a cgi program. The cgi (C) program gets the data through its arguments.

cgi.exe  -f1 data1 -f2 data2 ...

The issue occurs when the data contains control/special characters. I suppose Javascript (or Browser) handles that. For example;
If I enter ampersand (!) character in the first field, it gets

cgi.exe -f1 "\041" ... (octal value)

Can anyone please give me some pointers about how to print the ascii value of it, instead of octals? Again, it is a dynamic form/field there is no special replacement at users end. They may enter anything they want.

Cheers,
0
malatya
Asked:
malatya
  • 3
  • 2
1 Solution
 
ZylochCommented:
Hi

Since it's probably the browser, at the cgi end, can't you use oct to change the octal number to a decimal. Then, use chr to figure it's character out.

Regards,
Zyloch
0
 
malatyaAuthor Commented:
Zyloch, thanks for the comment. Unfortunately, it is not easy to convert the octals to ascii at cgi end. Not impossible but the argument might be composed of octals and asciis together. You need to differenciate the charcter whether it is octal/hex or ascii then do something accordingly.
0
 
ZylochCommented:
You might try this at the perl end:

s/\\(d+){3}/chr(oct($+))/gi

Regards,
${Zyloch}
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
malatyaAuthor Commented:
Actually, I found a solution. Before the scripts pass the arguments to cgi it echoes with -e option and works perfectly.

(bash) echo -e <the argument> > cgi

0
 
ZylochCommented:
Ah, that's good, then you should post in Community Support to close and refund this question. Glad you figured it out :)
0
 
LunchyCommented:
Closed, 100 points refunded.
Lunchy
Friendly Neighbourhood Community Support Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now