Javascript escaped in OSUI widget

I have really hit a brick wall, 


I have two pages, one is pulling in Client Data and creating an overly long form, This form is being cut into common areas and bundled into an Accordion (OS UI nex not Web Patterns)


This is what is happening, 

$('#RichWidgets_wt183_block_wtMainContent_OutSystemsUIWeb_wtClientDetailsAccordionContainer_block_wtContent_OutSystemsUIWeb_wtMaintainenceAndConfigAccordion_block_wtContent_wtClient_Color_Background').spectrum({  \r\n    showInput:true,\r\n    showinitial:true,\r\n    allowEmpty:true,\r\n    preferredFormat: \x27hex\x27\r\n ,color: \x27\x27} );



All new lines are escaped, this is OS default settings with no custom script in the page, does anyone know why this is happening?

It is breaking the rest of the page in that I have a colour picker it is not working because the OS JS is broken.


Contrarily I have another page with an input field, I am trying to ESCAPE this data to prevent script injection 


If I give a name like this:


<script>alert('hiya')</script> the inpout is not escaped (despite setting 'escaped' in the input fields)


When saved and displayed in a user details form, the alert is executed... Not good.


so I have two pages that are both using the incorrect method to parse the JS, I need each page to work the way the other is working!


the Accordion needs to be sorted so the colour picker works and the input fields need to be escaped to prevent the  JS being executed.


Please can anyone point me in the right direction?




Hi,

Below is how you add a javascript to the screen, you see how I have encodedjavascript in the expression so that the Server variable are encoded and you can avoid script injection.

Can you provide module so that I can check and help.

Thanks.