Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Re: Template-output quoting (Warning: Contains JavaScript)

by perlcgi (Hermit)
on Dec 11, 2002 at 10:34 UTC ( #219049=note: print w/replies, xml ) Need Help??

in reply to Re: Template-output quoting (Warning: Contains JavaScript)
in thread Template-output quoting (Warning: Contains JavaScript)

Dear dingus and tachyon, (and anyone else whose listening),
Thanks for taking the trouble to respond and for pointing out how the regex expertise we lean form perl can easily be taken to JavaScript. ( I guess the same is true now for Java and C#).
Anyways, my problem remains, perhaps because I have not explained the problem properly - the template codes can expand to any arbitrary string - so for example the template could expand to a string like:
Larry said "Let there be light"; Bill swallowed hard.
This gives a runtime error on my IE5.5 with JS debugging turned on. e.g.
var problem = "Larry said "Let there be light"; Bill swallowed hard";
Do you get my problem? Maybe it's impossible without opening the black-box.
Thanks again for any suggestions, guys.

Replies are listed 'Best First'.
Re: Re: Re: Template-output quoting (Warning: Contains JavaScript)
by tachyon (Chancellor) on Dec 11, 2002 at 11:19 UTC

    From what you are saying the way that the templating system is working is to arbirarily insert vars into the HTML as a pre-process. As such it can arbitrarily break your javascript before it can run. In this case by far the easiest solution, in fact probably the only solution will be to attack the source and send correctly escaped strings s/([^\w])/\\$1/g;

    The only other possible solution that occurs to me is trick the javascript thusly (pseudo code)

    <script> /* <VAR1> $var1 </VAR1> <VAR2> $var2 </VAR2> */ // now provided $var1 and $var2 did not contain the */ sequence // we should have all their values in pseudo XML within our // script. so now all we need to do is read the comment // somehow (don't know how but or some // such probably holds the entire HTML text) and then use some regex // magic to extract the values we want // begin magic... </script>

    We trick the javacript to thinking that




      Absolutely great idea, tachyon. Thank you! This is exactly the type of solution I was looking for.
      You are thinking outside the box!
      Take care in those flying machines,

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://219049]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2022-12-10 05:20 GMT
Find Nodes?
    Voting Booth?

    No recent polls found