By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,992 Members | 934 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,992 IT Pros & Developers. It's quick & easy.

unterminated string constant

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
"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.