How to escape data in PB generated javascript?

Hi,

The problem is when we have data in ESS which contains the
exact string =93</script>=94. In ESS, PB auto generates some
javascript which contain the data in the datawindows:

<SCRIPT LANGUAGE=3d"JavaScript">

htmldw.context =3d "(htmldw 0)(93797 (InsertRow 0 ((1 0
'2011-01-13 00:00:00:000000')(2 0 '</script>foo')(3 0
'S1')(4 0 'The ABC Company')(5 0 'A2')(6 0 'Test Title A
')(7 0 'AB')(8 0 'Test Title B')(9 0 'AD3')(10 0 'Test Title
C')(11 0 'AD3')(12 0 'Test Title D')(13 0 'N')(14 0 'P')(15
0 '79630')(16 0 '1806')(17 0 '1806')(18 0 '76368')(19 0
'2011-01-13 11:25:35:040000')(20 1 )(21 1 )(22 0 '76368')(23
0 'JOHN H. DOE)(24 0 '-1')(25 1 )(26 0 '2011-01-14
00:00:00:000000')(27 0 '2011-01-14 00:00:00:000000')(28 1
)(29 1 )(30 1 )(31 1 )(32 1 )(33 0 '0')(34 0 'N')(35 0
'P')(36 1 )(37 1 )(38 0 'P')(39 0 '1806')(40 1 )(41 1 )(42 1
)(43 0 'leaveapplication')(44 0 'F')(45 1 )(46 1 )(47 1 )(48
0 '1')(49 1 )(50 1 )(51 0 '0'))))";

</script>

The problem with javascript is that there cannot be a string
literal which contains =93</script>=94 because browsers will
take it as the end of the scripting. This is a problem for
all browsers. The solution is basically to escape html
special characters in the data before outputting it into
javascript form:

</script> becomes &lt;/script&gt;

In the datawindows section PB already does this
automatically:

<TEXTAREA NAME=3d"remarks"  ROWS=3d2 WRAP
CLASS=3dhtmldw16E68 TABINDEX=3d-32766
STYLE=3d"position:absolute; left:1.666in; top:2.073in;
width:8.855in"
onFocus=3d"{htmldw.itemGainFocus(0,2,this,htmldw.gobs.remarks);
htmldw.selectControlContent(this);}" onClick=3d"{var ret; 
ret=3d htmldw.itemClicked(0,2,'remarks',1); return ret;}"
onChange=3d"{this.bChanged =3d true;}" onkeypress=3d"return
DW_EditKeyPressed(event, this, -1);"
onBlur=3d"{htmldw.itemLoseFocus
(this);}">&lt;/script&gt;</TEXTAREA>

So the question is, how can we escape the data before PB
generates it=92s javascript?

Any advice would be very much appreciated.
Thanks.
0
Jason
1/13/2011 3:39:08 AM
sybase.powerbuilder.general 62418 articles. 11 followers. Follow

2 Replies
775 Views

Similar Articles

[PageSpeed] 58

Hi Jason,

What is ESS?

Apart of this, what is the exact control you're using to display such 
"</script>" string?
What version of PB are you using?

Maybe a possible workaround for you would be to HtmlEncode the value like 
this:

string ls_myvalue = "</script>"
string ls_myvalue_display

#if defined PBWEBFORM then
   System.Web.HTTPServerUtility Server = 
System.Web.HttpContext.Current.Server
   ls_myvalue_display = Server.HtmlEncode(ls_myvalue)
#end if

How's that?

Regards,
Ivaylo

<Jason L> wrote in message news:4d2e73dc.77b.1681692777@sybase.com...
Hi,

The problem is when we have data in ESS which contains the
exact string "</script>". In ESS, PB auto generates some
javascript which contain the data in the datawindows:

<SCRIPT LANGUAGE="JavaScript">

htmldw.context = "(htmldw 0)(93797 (InsertRow 0 ((1 0
'2011-01-13 00:00:00:000000')(2 0 '</script>foo')(3 0
'S1')(4 0 'The ABC Company')(5 0 'A2')(6 0 'Test Title A
')(7 0 'AB')(8 0 'Test Title B')(9 0 'AD3')(10 0 'Test Title
C')(11 0 'AD3')(12 0 'Test Title D')(13 0 'N')(14 0 'P')(15
0 '79630')(16 0 '1806')(17 0 '1806')(18 0 '76368')(19 0
'2011-01-13 11:25:35:040000')(20 1 )(21 1 )(22 0 '76368')(23
0 'JOHN H. DOE)(24 0 '-1')(25 1 )(26 0 '2011-01-14
00:00:00:000000')(27 0 '2011-01-14 00:00:00:000000')(28 1
)(29 1 )(30 1 )(31 1 )(32 1 )(33 0 '0')(34 0 'N')(35 0
'P')(36 1 )(37 1 )(38 0 'P')(39 0 '1806')(40 1 )(41 1 )(42 1
)(43 0 'leaveapplication')(44 0 'F')(45 1 )(46 1 )(47 1 )(48
0 '1')(49 1 )(50 1 )(51 0 '0'))))";

</script>

The problem with javascript is that there cannot be a string
literal which contains "</script>" because browsers will
take it as the end of the scripting. This is a problem for
all browsers. The solution is basically to escape html
special characters in the data before outputting it into
javascript form:

</script> becomes &lt;/script&gt;

In the datawindows section PB already does this
automatically:

<TEXTAREA NAME="remarks"  ROWS=2 WRAP
CLASS=htmldw16E68 TABINDEX=-32766
STYLE="position:absolute; left:1.666in; top:2.073in;
width:8.855in"
onFocus="{htmldw.itemGainFocus(0,2,this,htmldw.gobs.remarks);
htmldw.selectControlContent(this);}" onClick="{var ret;
ret= htmldw.itemClicked(0,2,'remarks',1); return ret;}"
onChange="{this.bChanged = true;}" onkeypress="return
DW_EditKeyPressed(event, this, -1);"
onBlur="{htmldw.itemLoseFocus
(this);}">&lt;/script&gt;</TEXTAREA>

So the question is, how can we escape the data before PB
generates it's javascript?

Any advice would be very much appreciated.
Thanks. 


0
Ivaylo
1/13/2011 7:21:09 AM
Hi Ivaylo,
Sorry about that, just ignore the term ESS, it's our web
application. We are using PB 10.5.

Thanks.

> Hi Jason,
>
> What is ESS?
>
> Apart of this, what is the exact control you're using to
> display such  "</script>" string?
> What version of PB are you using?
>
> Maybe a possible workaround for you would be to HtmlEncode
> the value like  this:
>
> string ls_myvalue = "</script>"
> string ls_myvalue_display
>
> #if defined PBWEBFORM then
>    System.Web.HTTPServerUtility Server =
> System.Web.HttpContext.Current.Server
>    ls_myvalue_display = Server.HtmlEncode(ls_myvalue)
> #end if
>
> How's that?
>
> Regards,
> Ivaylo
>
> <Jason L> wrote in message
> news:4d2e73dc.77b.1681692777@sybase.com... Hi,
>
> The problem is when we have data in ESS which contains the
> exact string "</script>". In ESS, PB auto generates some
> javascript which contain the data in the datawindows:
>
> <SCRIPT LANGUAGE="JavaScript">
>
> htmldw.context = "(htmldw 0)(93797 (InsertRow 0 ((1 0
> '2011-01-13 00:00:00:000000')(2 0 '</script>foo')(3 0
> 'S1')(4 0 'The ABC Company')(5 0 'A2')(6 0 'Test Title A
> ')(7 0 'AB')(8 0 'Test Title B')(9 0 'AD3')(10 0 'Test
> Title C')(11 0 'AD3')(12 0 'Test Title D')(13 0 'N')(14 0
> 'P')(15 0 '79630')(16 0 '1806')(17 0 '1806')(18 0
> '76368')(19 0 '2011-01-13 11:25:35:040000')(20 1 )(21 1
> )(22 0 '76368')(23 0 'JOHN H. DOE)(24 0 '-1')(25 1 )(26 0
> '2011-01-14 00:00:00:000000')(27 0 '2011-01-14
> 00:00:00:000000')(28 1 )(29 1 )(30 1 )(31 1 )(32 1 )(33 0
> '0')(34 0 'N')(35 0 'P')(36 1 )(37 1 )(38 0 'P')(39 0
> '1806')(40 1 )(41 1 )(42 1 )(43 0 'leaveapplication')(44 0
> 'F')(45 1 )(46 1 )(47 1 )(48 0 '1')(49 1 )(50 1 )(51 0
> '0'))))";
>
> </script>
>
> The problem with javascript is that there cannot be a
> string literal which contains "</script>" because browsers
> will take it as the end of the scripting. This is a
> problem for all browsers. The solution is basically to
> escape html special characters in the data before
> outputting it into javascript form:
>
> </script> becomes </script>
>
> In the datawindows section PB already does this
> automatically:
>
> <TEXTAREA NAME="remarks"  ROWS=2 WRAP
> CLASS=htmldw16E68 TABINDEX=-32766
> STYLE="position:absolute; left:1.666in; top:2.073in;
> width:8.855in"
> onFocus="{htmldw.itemGainFocus(0,2,this
> ,htmldw.gobs.remarks); htmldw.selectControlContent(this)
> ;}" onClick="{var ret; ret= htmldw.itemClicked(0,2
> ,'remarks',1); return ret;}" onChange="{this.bChanged =
> true;}" onkeypress="return DW_EditKeyPressed(event, this,
> -1);" onBlur="{htmldw.itemLoseFocus
> (this);}"></script></TEXTAREA>
>
> So the question is, how can we escape the data before PB
> generates it's javascript?
>
> Any advice would be very much appreciated.
> Thanks.
>
>
0
Jason
1/13/2011 8:13:11 AM
Reply:

Similar Artilces:

Generating PowerBuilder Applications from Data Model
A few years ago I used a version of PowerDesigner (perhaps AppModeller) to generate a functioning PowerBuilder application directly from a physical data model. It was fine for editing static data. I now have PowerDesigner 9.5.0 and want to do it again for static data. I can't find how to do it in this version of PowerBuilder. Any ideas? The functionality of AppModeler was not carried forward to PD 7, 8 or 9.x. However, using the 9.5.2 release, you are able to generate and reverse engineer PB extended attributes in the PDM. In the OOM, you can now reverse engineer your entire...

data, data, data
Hello, I need some advice on the best method to keep a database updated in this scenario. I have a local Solomon SQL Server where we keep our inventory. I want to build an application that will be hosted at a remote hosting location which provides a SQL database. I want to build the application to allow clients to access the inventory items and make requests based on the remote SQL data. The order will be sent to our fulfillment department via email; they will fiill the request and ship.  I'm not sure the method to do this while keeping the data current on the remote and the l...

JavaScript not generated by PB Comp in Jaguar 3.6 (Solaris)
I am running a PB Component in Jaguar 3.6 on Solaris 7 which generates the HTML and return to the Browser. This is a Stateless Component. I am doing this way to take advantage of Jaguar Conn Cache and Instance Pooling. But, JavaScript is not generated in the HTML which is returned to the Browser. Due to this, my navigation buttons and other functionalities are not working in the Browser. In the Datawindow Object, i have checked all the properties to generate javascript (like Generate javascript, Client formatting, client validations etc ....). The same Component is working fine i...

Dynamic table generation by JavaScript, Accessing row and data of dynamic table in C# code
  <div>   <input id="txtName" type="text"/> <input id="txtAdd" type="text"/> <input id="txtCity" type="text"/>   <input id="btnAdd" type="button" value="Add" onclick="AddClick();" /> <input id="btnRemove" type="button" value="Remove" onclick="RemoveClick(this);"/><br /> <table id="tblInfo" runat="server" style="width: 474px" > </table> </div&g...

"Bad Unicode escape sequence" error compiling JagMan generated (off-PB) Java file
Hello everyone. While using PB components from my EJBs, I've been having the following problems while compiling the off-PB Java code: Here goes the snippet of the compiled listing with error << package com.bny.sga; /** ** Generated by Jaguar CTS 3.5 - Wed Mar 22 16:17:34 EST 2000 ** SC-6 Bad Unicode escape sequence. ** from Sga::u_report_retriever (file D:\Program Files\Sybase\Jaguar CTS 3.5\Repository\IDL\Sga\u_report_retriever.idl, line 31). ** ** Please do not modify this file. **/ . . . . . . . . . >> There was a workaround, sure. I could ad...

where isthe "Generate Data in Data"
Hi everyone, I'm new to visual studio .NET 2005. Please helpI follow the " walkthroughs: displaying Data in a web forms page "when come to the "To generate a dataset" part I encounter an problem that I cant create Datasetbecause I do not see "Generate Dataset" under the Data menu.  PLease help.is there a another way to create dataset.  Could someone show me how.  Thank you very much. Hi ethantr, Based on my understanding, you probably followed this article: Walkthrough: Displaying Data in a Web Forms Pagehttp://msdn2.m...

How to convert a decimal data to binary data in PB
How to convert a decimal data to binary data in PB? Thanks Joe ...

HTML Generator generates different code in PB 11
We are in process of migration an web application (Jaguar 5.2 + Powerbuilder 9 to Jaguar 5.5 + PowerBuilder 11.5.1). I have run a simple test by generation HTML for a datawindow and noticed following problem: Example: PB9: <INPUT TYPE="text" NAME="test_0" SIZE=9 VALUE="test" CLASS=htmldw9D TABINDEX=1 STYLE="position:absolute; left:0.105in; top:0.010in; width:0.624in" onFocus= PB11.5.1 <INPUT TYPE="text" NAME="test_0" SIZE=9 VALUE="test" CLASS=htmldw27 TABINDEX=1 STYLE="position:absolute; left:0....

Data or Data
I pronounce it "data". HTH I pronounce it dAta and data. Depends upon my mood and the context it's in. Like I preserve dAta, but i lose data. :P Matthew wrote: > I pronounce it dAta and data. Depends upon my mood and the context it's > in. Like I preserve dAta, but i lose data. :P Lt Commander D "ay" ta. Nuff said. In fact he corrected Dr Pulaski when she called him D "ah" ta. D ay ta, d ah ta, what's the difference? One is my name... the other is not. :) <-geek > > Lt Commander D "ay&quo...

how to insert data in to the data base from a dynamically generated user control
Hi, I am loading one user control dynamically multiple times in a single page inside of an dynamically generated html table row. I am able to load that user contol dynamically multiple times, but the problem is , i want to enter data in the dynamically loaded user control's text boxes and insert the same data in to the database tables. please provide me a simple example to insert data in to the data base from dynamically generated user control. ?   The code for dynamically loading an user control which i have written is as follows:   using System; using System.Data; using...

PowerBuilder Crashes when trying to access data window data source
Hi there, I installed powerbuilder on a new computer and now it crashes when I open a data window and then try to access the data source (SQL). It bombs out completely with no error message. The version of powerbuilder is8.0 and it worked fine on the previous computer. I have regenerated the data window, exported and imported the data window etc but nothing seems to fix the problem. The problem also occurs if I make a new data window. I can access the database (oracle) in the database painter fine. Anyone any idea what is going on ? Thanks Hugh > I installed p...

generating a custom webpage in PB from a generated table and html template
Hey Y'all: I don't have any clue where to start here on this part. This is my problem: I need to get a functionality provided in a legacy access 2000 app into my PB development. What is does is this: Our users have a website where on one their pages is a project status page. It lists the studies and what their current status is. What's being used now is this: An access form called projects has an sql which generates the resultset. When the user clicks on the internet option from the reports form, projects' output is generated into an HTML table which in turn...

Generate PowerBuilder...
Hi, I'm new to PowerDesigner. I have PowerDesigner Version 8 Object Architect. I'm going through the process of defining the procedures that have to happen using PD8 to create an application using PowerBuilder 7. As a learning process, I've created a few use cases, defined classes from these and used the option to "Generate PowerBuilder..." to generate the code for these objects. My problem is that the code for the objects do not import correctly into PowerBuilder or generate the PBL correctly. 1. The comments field on the general tab of the properties...

Data Data :|
Ok, i have a very simple access database called score with just one table called high. This is just going to be used to keep the current score of a higher scorer and there name However, when the page loads i want the user to see this current high score and the persons name, but just one record i only ever want this to hold one record aswell..When the user finish’s the game there score is currently presented to them, when this happens i would like to connect to the database and check weather there score is higher than the current score (may have changed since they loaded page...

Web resources about - How to escape data in PB generated javascript? - sybase.powerbuilder.general

JavaScript Kit- Your comprehensive JavaScript, DHTML, CSS, and Ajax stop
Your comprehensive JavaScript, DHTML, CSS, and Ajax stop

Let's Code: Test-Driven Javascript by James Shore — Kickstarter
James Shore is raising funds for Let's Code: Test-Driven Javascript on Kickstarter! A screencast series focusing on rigorous, professional Javascript ...

Eloquent JavaScript: A Modern Introduction to Programming
... and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript! ...

JavaScript - Wikipedia, the free encyclopedia
programming styles. JavaScript was formalized in the ECMAScript language standard and is primarily used in the form of client-side JavaScript ...

Open Directory - Computers: Programming: Languages: JavaScript: Tools: Obfuscators
... editor - report abuse/spam - help the entire directory only in Tools/Obfuscators Description Top : Computers : Programming : Languages : JavaScript ...

Facebook Open-Sources JavaScript Static-Type Checker Flow
The latest software to be open-sourced by Facebook is Flow , a static-type checker for JavaScript . (more…) New Career Opportunities Daily: ...

Under the Hood: The JavaScript SDK - The use of polyfills - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Under the Hood: The JavaScript SDK - The use of polyfills geschrieben. Du kannst den vollständigen ...

JavaScript
The Facebook SDK for JavaScript provides a rich set of client-side functionality for adding Social Plugins, making API calls and implementing ...

Facebook App Devs Get Javascript
It has been an oft-lamented fact of the Facebook Platform thus far in its life that, in order to use all but the most simple of Javascript functionality–the ...

Badass JavaScript (@badass_js) on Twitter
WebGLWorker is an open source library that allows using WebGL from Web Workers. Great work as always from @kripken . blog.mozilla.org/research/2014/… ...

Resources last updated: 1/9/2016 9:23:02 PM