Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: Free Nodelet Hack: Add parent & root links to nodes in 'Nodes You Wrote' (escape)

by tye (Cardinal)
on Dec 22, 2006 at 17:32 UTC ( #591360=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Free Nodelet Hack: Add parent & root links to nodes in 'Nodes You Wrote' (or anywhere)
in thread Have parent 'Node ID' as link in 'Nodes You Wrote' node

if ( `_redir` == "root" )

No, that'd turn into one of the following, either:

if ( root == "root" )

or

if ( `_redir` == "root" )

neither of which looks like valid javascript to me. So you'd want something more like:

if ( "`_redir`" == "root" )

which would induce a syntax error if somehow you got a quote (or perhaps a trailing backslash) in your parameter value.

There needs to be an escape specifier for use in javascript strings. Perhaps:

if ( "`_redir\`" == "root" )

where that trailing \ tells the Free Nodelet templating to apply quotemeta to the parameter value (not implemented yet). I haven't checked exactly how escaping works in javascript strings, so quotemeta might not be appropriate. Perhaps `_redir"` would surround it in quotes and escape as appropriate.

- tye        


Comment on Re^3: Free Nodelet Hack: Add parent & root links to nodes in 'Nodes You Wrote' (escape)
Select or Download Code
Re^4: Free Nodelet Hack: Add parent & root links to nodes in 'Nodes You Wrote' (escape)
by ikegami (Pope) on Dec 22, 2006 at 18:21 UTC

    root is a URI component, so it could be escaped.

    if ( decodeURIComponent(`_redir"`) == "root" )

    I've discussed the need for a variables returned as JavaScript literals before. I even provided a workaround.

    if ( decodeURIComponent(decodeURIComponent('`_redir%`')) == "root" )
    if ( decodeURIComponent( '`_redir%`' ) == "root" )

      I'm not sure why you are thinking that it needs to be decoded twice. `_redir` expands to the parameter value, not to how that value might have been escaped in order to get passed through HTTP.

      I was aware of your work-around, which was part of why I was aware that a better solution was warranted. But, with the better solution, decodeURIComponent() would not be required.

      - tye        

        not to how that value might have been escaped in order to get passed

        Of course! I should have tested first :(

        I'm so used to seeing escaping an unescaping not being done when it should, I sometimes assumes it isn't done.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (16)
As of 2015-07-01 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (5 votes), past polls