469,360 Members | 1,686 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

unterminated string constant

Hi,

I am facing a problem in javascript. strdata is a variable of
javascript and following is an assignment( hmmmmmmmmmmm a Huge one but
unfortunately its not mine code, I am just trying to rectify it) to
this varibale.. Now I am facing a run time error(Unterminated string
constant). Can any one please help me solving this bug.
strdata +="<tr <% if functionality_add = 0 and functionality_edit = 0
and functionality_delete = 0 then %>style='visibility:hidden'<% end if
%>><td valign=top colspan=2 class='formField' height='25'
style='display:none' id='R_F" +curNode.item(0).text + "'><% if
functionality_add <> 0 or functionality_edit <> 0 then %>Sub Region /
City: <% end if %><font color='#FF0000' size='2'>*</font>&nbsp;<input
size='40' class='inputBox' maxlength='200' type='text'
name='city_"+curNode.item(0).text +"'<% if functionality_add = 0 and
functionality_edit = 0 then %>style='visibility:hidden'<% end if
%>>&nbsp;<select name='reg_type_"+curNode.item(0).text
+"'class='drpdwn' <% if functionality_add = 0 and functionality_edit =
0 then %>style='visibility:hidden'<% end if %>><option value=1>Sub
Region</option><option value=2>City</option></select><input class='Btn'
type=button name='addBtn2_"+curNode.item(0).text+"' value='Add'
onClick='submit_form(2)'" <% if functionality_add = 0 then
%>"style='visibility:hidden'" <% end if %>><input class='Btn'
type=button value='Edit' name='edBtn2_"+curNode.item(0).text+"'
onclick='gotoEditMode_2(" +curNode.item(0).text + ")' disabled <% if
functionality_edit = 0 then %>style='visibility:hidden' <% end if
%>><input width=75 disabled name='delBtn2_"+curNode.item(0).text+"'
type='button' class='Btn' value='Delete' onclick='delregion(2)' <% if
functionality_delete = 0 then %>style='visibility:hidden' <% end if
%></td></tr>"

Regards,
Amit Arora

Dec 8 '05 #1
3 3876
VK

aroraami...@gmail.com wrote:
Hi,

I am facing a problem in javascript. strdata is a variable of
javascript and following is an assignment( hmmmmmmmmmmm a Huge one but
unfortunately its not mine code, I am just trying to rectify it) to
this varibale.. Now I am facing a run time error(Unterminated string
constant). Can any one please help me solving this bug.


It is not a bug: new line cannot be used inside of a string literal.

The conventional way for long literals is:

var str = "";
str+= "hhhhhhhhhhhhhhhhhhhhhh";
str+= "uuuuuuuuuuuuuuuuuuuuuu";
str+= "gggggggggggggggggggggg";
str+= "eeeeeeeeeeeeeeeeeeeeee";

There is also a native (means common for all JavaScript/JScript
implementations) model failure exploit which allows you to do things
like:
(Google news swallows the backslashes, so instead of a real one I'm
using [backslash] marker)

var str = "[backslash]
hhhhhhhhhhhhhhhhhhhhhh[backslash]
uuuuuuuuuuuuuuuuuuuuuu[backslash]
gggggggggggggggggggggg[backslash]
eeeeeeeeeeeeeeeeeeeeee";

Note that [backslash] must to be the last char in the string. Also as
any exploit it is not guranteed to stay forever.

Dec 8 '05 #2
VK wrote on 08 dec 2005 in comp.lang.javascript:

aroraami...@gmail.com wrote:
Hi,

I am facing a problem in javascript. strdata is a variable of
javascript and following is an assignment( hmmmmmmmmmmm a Huge one but
unfortunately its not mine code, I am just trying to rectify it) to
this varibale.. Now I am facing a run time error(Unterminated string
constant). Can any one please help me solving this bug.


It is not a bug: new line cannot be used inside of a string literal.

The conventional way for long literals is:

var str = "";
str+= "hhhhhhhhhhhhhhhhhhhhhh";
str+= "uuuuuuuuuuuuuuuuuuuuuu";
str+= "gggggggggggggggggggggg";
str+= "eeeeeeeeeeeeeeeeeeeeee";

There is also a native (means common for all JavaScript/JScript
implementations) model failure exploit which allows you to do things
like:
(Google news swallows the backslashes, so instead of a real one I'm
using [backslash] marker)

var str = "[backslash]
hhhhhhhhhhhhhhhhhhhhhh[backslash]
uuuuuuuuuuuuuuuuuuuuuu[backslash]
gggggggggggggggggggggg[backslash]
eeeeeeeeeeeeeeeeeeeeee";

Note that [backslash] must to be the last char in the string. Also as
any exploit it is not guranteed to stay forever.


var str =
'hhhhhhhhhhhhhhhhhhhhhh'+
'uuuuuuuuuuuuuuuuuuuuuu'+
'gggggggggggggggggggggg'+
'eeeeeeeeeeeeeeeeeeeeee';

var str =
'hhhhhhhhhhhhhhhhhhhhhh'
+'uuuuuuuuuuuuuuuuuuuuuu'
+'gggggggggggggggggggggg'
+'eeeeeeeeeeeeeeeeeeeeee';

var str = ''.concat(
'hhhhhhhhhhhhhhhhhhhhhh',
'uuuuuuuuuuuuuuuuuuuuuu',
'gggggggggggggggggggggg',
'eeeeeeeeeeeeeeeeeeeeee');

var str = [
'hhhhhhhhhhhhhhhhhhhhhh',
'uuuuuuuuuuuuuuuuuuuuuu',
'gggggggggggggggggggggg',
'eeeeeeeeeeeeeeeeeeeeee']
..join('');

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Dec 8 '05 #3
"VK" <sc**********@yahoo.com> writes:
There is also a native (means common for all JavaScript/JScript
implementations)
That's a broad sweep :)
model failure exploit which allows you to do things like:
(Google news swallows the backslashes, so instead of a real one I'm
using [backslash] marker)

var str = "[backslash]
hhhhhhhhhhhhhhhhhhhhhh[backslash]
uuuuuuuuuuuuuuuuuuuuuu[backslash]
gggggggggggggggggggggg[backslash]
eeeeeeeeeeeeeeeeeeeeee";


While it might work in most Javascript implementations, what it means
is different. In some browsers, the "backslash newline" is not in the
resulting string (e.g., IE, Opera and Mozilla), in others the newline
itself is escaped and occurs in the string (e.g., Netscape 4).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Dec 8 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by noViagraHere | last post: by
2 posts views Thread by polilop | last post: by
5 posts views Thread by ken s | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.