Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > unterminated string constant

Reply
Thread Tools

unterminated string constant

 
 
aroraamit81@gmail.com
Guest
Posts: n/a
 
      12-08-2005
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

 
Reply With Quote
 
 
 
 
VK
Guest
Posts: n/a
 
      12-08-2005

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.

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      12-08-2005
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)

 
Reply With Quote
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      12-08-2005
"VK" <> 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 -
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unterminated string constant =?Utf-8?B?a2VuIHM=?= ASP .Net 5 10-20-2006 06:55 PM
XMLHttpRequest - unterminated string constant javascript error William Javascript 18 01-25-2006 11:47 PM
Unterminated string constant - what causes it? Tav Javascript 2 01-09-2006 03:06 PM
unterminated string constant aroraamit81@gmail.com Javascript 3 12-08-2005 01:17 PM
Need help with unterminated string constant ... Jeff Javascript 4 05-07-2004 12:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57