Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,491,381
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-27-24 06:13 AM
Guest: Register | Login

0 users currently in Help/Suggestions/Bug Reports | 1 guest

Main - Help/Suggestions/Bug Reports - tvalidate() New thread | New reply


NightKev
Posted on 08-28-10 01:50 PM Link | Quote | ID: 135000


Cape Luigi
Level: 131

Posts: 4373/4792
EXP: 26231718
Next: 192902

Since: 03-15-07

Last post: 3735 days
Last view: 3647 days
This will fix it so it won't explode if you have <table>/etc inside of [code] tags.

function tvalidate($str)

{
$l=strlen($str);
$isquot=0; $istag=0; $isneg=0; $iscomment=0; $params=0; $codetag=0;
$t_depth=0;

for($i=0;$i<$l;++$i)
{
if(!strcmp(substr($str,$i,6),'[code]'))
$codetag=1;
if(!strcmp(substr($str,$i,7),'[/code]'))
$codetag=0;

if(($str[$i]=='\"' || $str[$i]=='\'') && $str[$i-1]!='\\')
$isquot=!$isquot;

if($str[$i]=='<' && !$isquot)
{
$istag=1;
$isneg=0;
$params=0;
}
elseif($str[$i]=='>' && !$isquot)
$istag=0;

if($str[$i]=='/' && !$isquot && $istag)
$isneg=1;

if(!strcmp(substr($str,$i,4),"<!--"))
$iscomment=1;

if(!strcmp(substr($str,$i,3),"-->"))
$iscomment=0;

if($istag && !$params && !$iscomment && !strcasecmp(substr($str,$i,5),'table') && !$codetag)
$t_depth+=($isneg==1?-1:1);

if($t_depth<0)
return -1; //disrupture

if($istag && !$params && !$iscomment && $t_depth==0 && !strcasecmp(substr($str,$i,2),'td') && !$codetag)
return -1; //td on top level

if($istag && !$params && !$iscomment && $t_depth==0 && !strcasecmp(substr($str,$i,2),'tr') && !$codetag)
return -1; //tr on top level

if($istag && $str[$i]!=' ' && $str[$i]!='/' && $str[$i]!='<')
$params=1;
}

return $t_depth;
}


____________________

blackhole89
Posted on 08-28-10 02:33 PM Link | Quote | ID: 135007


The Guardian
Moloch whose eyes are a thousand blind windows!
Level: 124

Posts: 3264/4196
EXP: 21534322
Next: 302279

Since: 02-19-07
From: Ithaca, NY, US

Last post: 472 days
Last view: 85 days



<table>


There were several problems with the code you suggested, but I fixed it up if it's really that much of a bother.

____________________



NightKev
Posted on 08-29-10 01:06 AM Link | Quote | ID: 135049


Cape Luigi
Level: 131

Posts: 4376/4792
EXP: 26231718
Next: 192902

Since: 03-15-07

Last post: 3735 days
Last view: 3647 days
Eh, it was screwing up my trying to post an IRC quote (apparently <trackwtf> == <table> ).

____________________

Mega-Mario
Posted on 08-29-10 01:52 AM Link | Quote | ID: 135056

Spamming from alt accounts.
Level: 81

Posts: 1187/1610
EXP: 4880466
Next: 112383

Since: 09-10-08

Last post: 3590 days
Last view: 3010 days
<trackwtf> does begin with <tr

so yeah

By the way, blacky, did you fix the newreply/editpost/editprofile/etc textboxes as to not eat HTML entities?

____________________
Kafuka -- ROM hacking
Kuribo64 -- we hack shit

blackhole89
Posted on 08-29-10 04:09 AM Link | Quote | ID: 135061


The Guardian
Moloch whose eyes are a thousand blind windows!
Level: 124

Posts: 3267/4196
EXP: 21534322
Next: 302279

Since: 02-19-07
From: Ithaca, NY, US

Last post: 472 days
Last view: 85 days



I believe to have done so long ago, but knowing me, I could be imagining it...

____________________



Mega-Mario
Posted on 08-29-10 05:33 PM Link | Quote | ID: 135086

Spamming from alt accounts.
Level: 81

Posts: 1192/1610
EXP: 4880466
Next: 112383

Since: 09-10-08

Last post: 3590 days
Last view: 3010 days
Well, apparently you missed certain places...

newreply and newthread are fine, but editpost still eats HTML entities. As well as the editprofile bio/header/signature fields.

____________________
Kafuka -- ROM hacking
Kuribo64 -- we hack shit

NightKev
Posted on 08-30-10 03:08 AM Link | Quote | ID: 135103


Cape Luigi
Level: 131

Posts: 4379/4792
EXP: 26231718
Next: 192902

Since: 03-15-07

Last post: 3735 days
Last view: 3647 days
Also, what was wrong with the pasted code? I haven't noticed any problems with it before.

____________________

blackhole89
Posted on 08-30-10 03:32 AM Link | Quote | ID: 135105


The Guardian
Moloch whose eyes are a thousand blind windows!
Level: 124

Posts: 3275/4196
EXP: 21534322
Next: 302279

Since: 02-19-07
From: Ithaca, NY, US

Last post: 472 days
Last view: 85 days



Minimal example:
<table>[code] <!-- [/code] </table> --> </table>

Your code would accept this.

____________________



Mega-Mario
Posted on 08-31-10 01:24 AM (rev. 2 of 08-31-10 01:25 AM) Link | Quote | ID: 135126

Spamming from alt accounts.
Level: 81

Posts: 1196/1610
EXP: 4880466
Next: 112383

Since: 09-10-08

Last post: 3590 days
Last view: 3010 days
And why bother with that tvalidate() thing in first place? If I were you, I'd just throw that overcomplicated headache-inducing shit out, and simply edit/delete offending posts with the moderator powers that are given to me.

Just giving my opinion.

Edit- about HTML entity greediness, newreply also eats 'em when quoting a post...

____________________
Kafuka -- ROM hacking
Kuribo64 -- we hack shit

NightKev
Posted on 08-31-10 07:00 AM Link | Quote | ID: 135139


Cape Luigi
Level: 131

Posts: 4381/4792
EXP: 26231718
Next: 192902

Since: 03-15-07

Last post: 3735 days
Last view: 3647 days
Posted by Mega-Mario
And why bother with that tvalidate() thing in first place? If I were you, I'd just throw that overcomplicated headache-inducing shit out, and simply edit/delete offending posts with the moderator powers that are given to me.
Because tvalidate() already exists, and trying to delete a post that's fucking with tables can get complicated.

____________________

Mega-Mario
Posted on 09-01-10 07:42 PM Link | Quote | ID: 135199

Spamming from alt accounts.
Level: 81

Posts: 1198/1610
EXP: 4880466
Next: 112383

Since: 09-10-08

Last post: 3590 days
Last view: 3010 days
Well, the edit/delete links for a post appear above it, and code-wise they come before the post contents, so I think that normally they shouldn't be affected by whatever table breaking you cause.

____________________
Kafuka -- ROM hacking
Kuribo64 -- we hack shit

NightKev
Posted on 09-02-10 06:59 AM Link | Quote | ID: 135222


Cape Luigi
Level: 131

Posts: 4384/4792
EXP: 26231718
Next: 192902

Since: 03-15-07

Last post: 3735 days
Last view: 3647 days
My first point still stands, regardless. Why try and fix it after the fact when you don't even have to worry about it in the first place ever?

____________________

Main - Help/Suggestions/Bug Reports - tvalidate() New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.023 seconds. (323KB of memory used)
MySQL - queries: 58, rows: 78/80, time: 0.016 seconds.