Jump to content


Photo

Fast reply post won't parse the javascript in a custom bbcode


See this post: http://community.inv...t/#entry2280936

This is a custom bbcode which simply swaps out a simple bbcode for a javascript line. When you do this with a fast reply, that resulting javascript doesn't show up. When you refresh the page, it does.

Status: Not a Bug
Version: 0
Fixed In: 0


12 Comments

Hmm, javascript is not supposed to work at all actually so something is wrong anyway.
javascript is not supported for replacements as mentioned by terabyte and as noted in the setting description. The javascript is now properly escaped during parsing to clear up the inconsistency between posting methods.
We can't use javascript in custom bbcodes anymore? So what exactly is the fix, making it so it doesn't parse at all anymore?
Yes, it's been like that since 3.x Michael.


Posted Image


This is also the reason we converted the spoiler bbcode to use a CSS class to attach a javascript event from ipb.js.
Just a quick note I forgot: I haven't tried it but a work-around could be to use a custom php plugin for the bbcode and return directly the JS from there. Not tested but *should* work in this way.

Just a quick note I forgot: I haven't tried it but a work-around could be to use a custom php plugin for the bbcode and return directly the JS from there. Not tested but *should* work in this way.

I can confirm that this doesn't work. There's no way for me to use Javascript in my custom BBCodes any more, please fix!

I can confirm that this doesn't work. There's no way for me to use Javascript in my custom BBCodes any more, please fix!


There is nothing to fix here, this is not a bug. It should not be possible to post javascript in bbcodes as Terabyte mentioned.
Photo
Marcher Technologies
Aug 16 2012 01:14 AM

There is nothing to fix here, this is not a bug. It should not be possible to post javascript in bbcodes as Terabyte mentioned.

hrmm, then would quote doing that ^ be one?
[ quote name='AndyMillne' timestamp='1344979896' collapse='1' ]
There is nothing to fix here, this is not a bug. It should not be possible to post javascript in bbcodes as Terabyte mentioned.
[ / quote ]
<p &#111;nclick="if($('emailquote-244408').style.display=='none'){$('emailquote-244408').style.display='inline';$('quotehelp-244408').style.display='inline';}else{$('emailquote-244408').style.display='none';}" class="citation">AndyMillne, on 14 August 2012 - 03:31 PM, said:</p>
>_< Got to really digging into bbcode_quote and thought of this report.
I've actually run into this same issue myself with the My Media replacement for Gallery images (which now shows a lightbox).

What I ended up doing was:
  • My media replacement includes an HTML comment
  • A global hook was added that overrides output class and searches for this HTML comment in the output
  • If it's present, a javascript file is appended to the page (added to js_modules array)
  • The javascript file then looks for the CSS class that was also included in the my media replacement and acts on it

It's a bit of a roundabout method, but it is working correctly whether posts are cached or not.
Photo
Marcher Technologies
Aug 16 2012 04:06 PM
Should I resubmit the above, as it isn't allowed? quote shouldn't do that, but I am unsure as to whether this is already fixed in 3.4 due to parsing changes.
yes, please submit a report for the quote issue. We'll need to look into that.
Updating Fixed In to: 0
Updating Status to: Not a Bug
Updating Version to: 0

I'm reverting this because it's the collapse="1" thing in quotes which Nexus uses.

There's nothing wrong with using Javascript in custom BBCode (and I've removed the message saying you can't) but as for the original issue being reported - if you inject a <script> tag into the DOM using AJAX (which is how fast reply works), it won't work - there's nothing we can do to fix that. So the original issue is Not A Bug.
    • Marcher Technologies likes this