Solved

Javascript and control characters

Posted on 2004-08-05
7
667 Views
Last Modified: 2008-03-06
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
Comment
Question by:malatya
  • 3
  • 2
7 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 11727372
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
 

Author Comment

by:malatya
ID: 11729276
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
 
LVL 36

Expert Comment

by:Zyloch
ID: 11729589
You might try this at the perl end:

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

Regards,
${Zyloch}
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:malatya
ID: 12071066
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
 
LVL 36

Expert Comment

by:Zyloch
ID: 12071082
Ah, that's good, then you should post in Community Support to close and refund this question. Glad you figured it out :)
0
 
LVL 2

Accepted Solution

by:
Lunchy earned 0 total points
ID: 12080092
Closed, 100 points refunded.
Lunchy
Friendly Neighbourhood Community Support Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

920 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

17 Experts available now in Live!

Get 1:1 Help Now