PDA

Click to See Complete Forum and Search --> : Problem with JavaScript:


Danial
Sep 8th, 2004, 01:09 PM
Hi it seems like if i type JavaScript: then a space between Java and script is inserted. Check this test post (http://www.vbforums.com/showthread.php?s=&postid=1782163#post1782163)

Its annoying sometime as you can see here (http://www.vbforums.com/showthread.php?s=&postid=1782129#post1782129)

Is it possible to fix it without modifying the "Underlying Forum Code"?

Thanks.

brad jones
Sep 8th, 2004, 02:29 PM
Hi it seems like if i type javascript: then a space between Java...

hi it seems like if i type JavaScript: then a space....

hi it seems like if i type "javascript" then....

Danial
Sep 8th, 2004, 02:52 PM
Brad, looks like you fixed it, thanks.


But if I edit my post, the problem re-appears, can you fixed that if possible.

Thanks again.

Danial.

brad jones
Sep 8th, 2004, 03:21 PM
I didn't do anything. The only time I could duplicate the error was when I copied your post.

I suggest you don't copy your post ;)

Brad!

Danial
Sep 8th, 2004, 03:30 PM
Originally posted by brad jones
I didn't do anything. The only time I could duplicate the error was when I copied your post.

I suggest you don't copy your post ;)

Brad!

Brad, apart from the first post in my test thread, i didnt copy. Wired thing is that now the edit the post its fine too :confused: . Are you sure you didnt change anything?

Electroman, did you copy my post or type it in my test theread? Because your recreated the error I am talking about.

Or you didnt change anything did you?

Anyhow the problem is resolved, but its was some wired AutoFix :D

brad jones
Sep 8th, 2004, 03:43 PM
Definitely weird. I wasn't sure where to being looking, which is why I started by trying to duplicate the issue.....

If it happens again and we can duplicate it, then I'll see what we can do. :)

Brad!

Danial
Sep 8th, 2004, 03:44 PM
Originally posted by brad jones
Definitely weird. I wasn't sure where to being looking, which is why I started by trying to duplicate the issue.....

If it happens again and we can duplicate it, then I'll see what we can do. :)

Brad!

I spoke too early, it only happens inside tag. e.g

[code]
onclick="javascript:Test()"


That should replicate the error.

Danial
Sep 8th, 2004, 03:49 PM
Brad, finally found the cause.

It happens inside [code], [vbcode], and [quote] tag.

When i edit the post, it shows the text without any space, so that means Format function of vbBulletin is causing the bug.

Electroman
Sep 8th, 2004, 07:04 PM
To be more precise it only happens when those tags are used in a post, but even then it affects outside the tags if they were present.

Like Look at these two posts:
http://www.vbforums.com/showthread.php?s=&action=showpost&postid=1782456
http://www.vbforums.com/showthread.php?s=&action=showpost&postid=1782457

The second one is the same as the first except the line with the Code tags has been taken out ;).

Danial
Sep 8th, 2004, 07:32 PM
Good work EM :thumb: , nearly freaked me out trying to re-create the error.

Hope brad can fix it :)

Electroman
Sep 9th, 2004, 07:28 AM
Solved the problem, well I found the reason I reckon......


I just tried it with the bold tags so its actually if any tags are present and the reason is that you could inject Javascript when tags with parameters are present. For example:

SomeText

converts to:

<font color="Red">SomeText</font> (Or similar)

So then what if you do:

SomeText

That would convert to:

<font color="Red" onclick="javascript:DoSomething()">SomeText</font> (Or similar)

Danial
Sep 9th, 2004, 04:32 PM
EMan,

I see your point, you are trying to say this can be used to call JavaScript function and would be open to abuse, right?

In that case all is needed is to put a tag like we do, between java and script

e.g Replace JavaScript to Java[b] [/b ]Script

Note that the "<script>" tag "<" and ">" is getting replaced by html char code so you would not be able to call any script any way. You can only do inline JavaScript.

I would assume we only need to modify the Replace function, e.g

Replace(strHtml, "JavaScript:", "Java Script:")
to
Replace(strHtml, "JavaScript:", "Java[b ][/b ]Script"

Obviously the equivelent of Replace function in PHP.


Brad any ways to fix it or is it too much code change?

Electroman
Sep 9th, 2004, 07:53 PM
I would think its rather a lot to change. You could just work around it by doing:

javascript:
javascript:

Which is actually how I managed to get it to display right in my last post. Ofcourse if this is the way to go then not everyone will know how to do it but at least then you'll know something not everyone else does :D.

Thing is this could have been fixed in the next version but I'm not sure there. the method you suggested could have some strange results, especially if you used that replace statement when the input was the injection I gave as an example ;).

brad jones
Sep 10th, 2004, 07:25 AM
I'll report this to our developers and see if they have the time to look into it.

Brad

Danial
Sep 10th, 2004, 08:17 AM
Originally posted by brad jones
I'll report this to our developers and see if they have the time to look into it.

Brad

Thanks Brad,

Its not a major issue, but would be nice if it can be fixed.