Helpful Information
 
 
Category: Suggestions & Feedback
[code] tag alert...

Would it be possible to have a little bit of JavaScript that when a
new post or thread was made or edited would check the post for
the existance of keywords like <script or <?php or <% or anything
else specific to various programming languages, and also look for
the existance of [code] or [php] tags, and if not, then create an
alert() box saying something like "It seems you are posting some
code, but it appears you have omitted [code] or [php] tags!".

I'm sure plenty of other people tire of seeing pages and pages of
code posted by n00bs who "didn't know any better".

Whatcha reckon?

I reckon it would be simple enough if you can workout where the code is that doesn't let you post less than 2 characters, etc.

That's done in a function called validateMessage() in global.js.

write the patch and submit it :)

me, I need to get to work on the shoutbox bracket bug :o

Yeah, I think this would be an awesoem idea. The only problem, is you can't really just check for code (other than markup languages) because the code can start with everyday words. And you can't really just check for ( or ) because they're common. The only thing you could really check for is { and } and MAYBE #.
Again this is talking everything that is not a markup language :P

He's not saying check for everything. Check for <?, <% and <script and you'll catch quite a few instances. The goal isn't to catch everything, just most of it.

---John Holmes...

me, I need to get to work on the shoutbox bracket bug :oSend them a fix that encodes the shout value when you edit it, also. Type </textarea><script>alert('hi');</script> as your shout and then edit it for an example.

I sent a ticket in about it, but it confused them, I think.

---John Holmes...

Send them a fix that encodes the shout value when you edit it, also. Type </textarea><script>alert('hi');</script> as your shout and then edit it for an example.

I sent a ticket in about it, but it confused them, I think.

---John Holmes...
sorry, I'm limited to one fix at a time till I get pomoted to mod :p ;)

sorry, I'm limited to one fix at a time till I get pomoted to mod :p ;)
OK we are going to look into these 2 fixes, can someone provide detailed step by step on how to fix both issues as that will expedite it.

what fixing B-Con and the mods? :o

The shoutbox I think needs striphtmlentities() or something added to it, because from what Sep is saying (don't want to try it myself), when editing your should it's putting html straight onto your front page (bad!).

I'm not sure about the two javascript fixes though.

what fixing B-Con and the mods? :o

The shoutbox I think needs striphtmlentities() or something added to it, because from what Sep is saying (don't want to try it myself), when editing your should it's putting html straight onto your front page (bad!).

I'm not sure about the two javascript fixes though.

I requested a detailed step by step walk thru - personally I think this stuff is nitpicky but Im willing to devote developer time to it if you guys are willing to provide a step by step on each thing you want modded.

1. Well, for my alert() idea, you should just be able to add something
like this:


//Check for [code] or [php] tags is necessary
else if ((messageText.toLowerCase().match(/(\<script)|(\<\?)|(\<\%)/)) && (!messageText.toLowerCase().match(/(\[code\])|(\[php\])/)))
{
alert(vbphrase["please_use_code_tags"]);
return false;
}
to the validatemessage() function in vbulletin_global.js

And add this to the vbphrase array:

"please_use_code_tags" : "You appear to be posting some code, but have omitted [code] or [php] tags from your message."

2. Or, ignore all that, and do the following:

//Check for [code] or [php] tags is necessary
else if ((messageText.toLowerCase().match(/(\<script)|(\<\?)|(\<\%)/)) && (!messageText.toLowerCase().match(/(\[code\])|(\[php\])/)))
{
if (confirm('You appear to be posting some code, but have omitted [code] or [php] tags from your message.\n\nClick OK to go back and add them, or cancel to continue without.')) return false;
else return true;
}That way, the user can either continue without entering code
tags, or can go back and put them in...

[2nd one's the better method IMO... ;)]

OK on the alert issue we will try your solution Chief. Now whats the walk through on the issue with the shout box?

Our forums use lot of different programmers. If we put any limitation to check the existents of <script, <?, <%, this going to harm lot of programmer who uses different programming languages. We have lot of visitors who posts codes in Perl, C, C++, Python, .Net, Delphi …etc. So if we planning to do something like this we have to cover all the programming languages which going to be really hard. If you have any ideas about it please let me know. And also some people might post only a small section from a program base on the thread discussion, which mean it is always not necessary to put whole code section which start and end with < />, { }, <? >, begin…end….etc.

Ok people we going to try this one for selected languages, so we can try to detect whether they posting a code or not.

To add other languages, you just need to add some keyword or
something specific to that language to the first regex.


He's not saying check for everything. Check for <?, <% and <script and you'll catch quite a few instances. The goal isn't to catch everything, just most of it.

---John Holmes...What he said. ^

If the user was only posting a small amount of code, the alert
might still show, but they have the option to ignore it if they
want...

We change the JavaScript to check for
<? <% <script <style <?xml <!-- <applet <html
Hope this will do the job.

this (http://forums.devshed.com/showpost.php?p=1055232&postcount=6) post just triggered the notice, but it doesn't appear to have any of the code you listed.

Is this across all forums or enabled for specific ones?

Good job overall, though. :)

---John Holmes...

Test.

<?










privacy (GDPR)