473,503 Members | 3,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Escape problem

Hi
I am developing a web application.
I have a string 'foo"bar"' say in variable s.
When I print s on the python shell it prints correctly 'foo"bar"'
whereas when I try to display s on the form it just prints 'foo'. What
should I do to print complete string 'foo"bar"' on the form
Jul 18 '05 #1
4 1308
Am Tue, 02 Mar 2004 06:57:19 -0800 schrieb ketulp_barod:
Hi
I am developing a web application.
I have a string 'foo"bar"' say in variable s.
When I print s on the python shell it prints correctly 'foo"bar"'
whereas when I try to display s on the form it just prints 'foo'. What
should I do to print complete string 'foo"bar"' on the form


Hi,

have a look at the HTML source-code. Does it look right?

If you want to use the value in an attribute,
you need to quote it:

cgi.escape(s, 1)

thomas

Jul 18 '05 #2
The exact answer depends on what library you're using in your
application.

THe low-level answer is that you must properly escape characters that
would otherwise be treated specially by html.

For example, the output needs to look like this
<FORM ...>
<INPUT TYPE="text" NAME="something" VALUE="foo&quot;bar&quot">
...
</FORM>

If you do not escape or otherwise treat specially the " characters, the
resulting non-html output will contain something like
<INPUT TYPE="text" NAME="something" VALUE="foo"bar"">

.... this kind of bug can also lead to cross-site scripting (XSS) problems,
for instance if an attacker can control the string in question and sets
it to something like '"><SCRIPT>alert(document.cookie)</SCRIPT>'...

Jeff

Jul 18 '05 #3

<ke***********@yahoo.com> wrote in message
news:f0**************************@posting.google.c om...
Hi
I am developing a web application.
I have a string 'foo"bar"' say in variable s.
When I print s on the python shell it prints correctly 'foo"bar"'
whereas when I try to display s on the form it just prints 'foo'. What
should I do to print complete string 'foo"bar"' on the form


If I understand correctly, you are trying to print a string with an
embedded double quote ("), which html interpretes as a metachar rather than
as content. Isn't there an entity reference for the double quote char?
named 'quote' maybe?

tjr


Jul 18 '05 #4
Jeff Epler <je****@unpythonic.net> wrote in message news:<ma*************************************@pyth on.org>...
The exact answer depends on what library you're using in your
application.

THe low-level answer is that you must properly escape characters that
would otherwise be treated specially by html.

For example, the output needs to look like this
<FORM ...>
<INPUT TYPE="text" NAME="something" VALUE="foo&quot;bar&quot">
...
</FORM>

If you do not escape or otherwise treat specially the " characters, the
resulting non-html output will contain something like
<INPUT TYPE="text" NAME="something" VALUE="foo"bar"">

... this kind of bug can also lead to cross-site scripting (XSS) problems,
for instance if an attacker can control the string in question and sets
it to something like '"><SCRIPT>alert(document.cookie)</SCRIPT>'...

Jeff


Thanks that solyed my problem
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
7953
by: KathyB | last post by:
Hi, not sure this is the right group, but hoping someone may have experienced this. I'm passing html text as a parameter to a javascript. When it has an apostrophe in it, of course it does parse...
3
4592
by: Paul | last post by:
I have an Access 2000 database with a form that is giving me some major headaches. When you open the form, it displays all records and allows editing, but has AllowAdditions set to False so that...
18
7148
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
0
1474
by: shravan | last post by:
Hi, I have a extended Windows Forms Datagrid, I have custom column styles defined for it. The problem is when I am in the new row and pressing escape two times - First time it's cancelling cell...
0
1100
by: YiFai | last post by:
Hello, I'm currently writing a directx program with C++, but it takes a while to load the files necessary for the directx. When the directx window loads, it can quit the program with the...
12
9615
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
7
4175
by: Axel Dahmen | last post by:
Hi, within a DataGrid control I'm using a DataTable containing a string column to fill a Hyperlink's href attribute. Unfortunately HttpUtility.UrlEncode() doesn't escape the apostroph character,...
15
18279
by: pkaeowic | last post by:
I am having a problem with the "escape" character \e. This code is in my Windows form KeyPress event. The compiler gives me "unrecognized escape sequence" even though this is documented in MSDN....
2
2504
by: Richard Lewis Haggard | last post by:
How does one specify the Escape key as an accelerator? My client has specified that the Escape key be used as an accelerator for a particular menu item. In VS05's designer mode, this particular...
5
15640
by: vlsidesign | last post by:
The printf function returns "warning: unknown escape sequence: \040" for a backslash-space combination. If the ascii decimal number for space is 32 and the backslash is 92, why this particular...
0
7192
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7064
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7315
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.