Jump to content
  • Advertisement
Sign in to follow this  
fastcall22

This chat, apparently, is a gigantic coding horror

This topic is 1416 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Yea when me+bact first discovered them(which was a complete accident, as bact was showing some code iirc, and it had ,A, in it) anyway me+him surmised it's some type custom encoding scheme, rather than using base64.

Also if you went through the source code did you try out the bad words?

Share this post


Link to post
Share on other sites

Also if you went through the source code did you try out the bad words?

I did not go through the source code, but I'm pretty positive this is what's going on. I know there are other quirks, but what do you mean by "trying out the bad words"?

Share this post


Link to post
Share on other sites
ipb.chat.badwords.set( 'yeahmobi', [ 1, "[A REALLY ANNOYING AND DISREPUTABLE COMPANY THAT SPAMS FORUMS]" ] );
ipb.chat.badwords.set( 'YeahMobi', [ 1, "[A REALLY ANNOYING AND DISREPUTABLE COMPANY THAT SPAMS FORUMS]" ] );
these however do not actually do anything when you type it into chat unfortuantly=-(

edit: also when i was reading the title, i expected code snippets of people in chat, not the chat itself =-P Edited by slicer4ever

Share this post


Link to post
Share on other sites
What, you mean like this thing that happened yesterday?


Stormynature+> L. Spiro I would never think of you as a whiner...just a very deep navel gazer confused by the mysteries of belly button lint
L. Spiro+> I did do some naval grazing back in my time.
riuthamus has entered the room
riuthamus> naval gazing....
riuthamus> i had to read the context to understand
riuthamus> now that i do, im not sure i wanted to...
NightCreature83+> so you go navel gazing instead?
fastcall22> suddenly, i have a strong feeling to clean my navel
fastcall22> my naval ship, that is
fastcall22> all aboard the u.s.s. yourmom, now taking off to the issofat island
riuthamus kicked fastcall22


EDIT:
Or do you mean like anything WiredCat posts? His code gives me nightmares... Edited by fastcall22

Share this post


Link to post
Share on other sites

Yes, I actually found the code that caused that issue. It comes from some "dirtyMessage" and "undirtyMessage" functions (can't check the exact names now, try and grep the JS code for "dirty") in the javascript code that do exactly what you are saying: replacing special symbols by encoded values to send them over the network. But the encoding and decoding functions are not inverses of each other, and in some circumstances the encoding is ambiguous, which causes the decoding function to decode the wrong thing, resulting in the bug observed. Basically, whoever implemented it tried to be smart, and failed.

 

Should've just used base64.

Edited by Bacterius

Share this post


Link to post
Share on other sites

It's especially funny since javascript already has a built in function called encodeURIComponent which replaces certain characters with their respective safe counterparts.

Share this post


Link to post
Share on other sites

Yeah that was my first thought, but I'm not sure if some symbols aren't still parsed after the decoding (can somebody who knows better confirm if this is the case or not?).

 

Also why + gets encoded to __PS__ and not __P__? *OCD mode kicks in*

Share this post


Link to post
Share on other sites

Okay, now that I've checked it's not "dirty" but "clean", close enough.. behold the cleanMessage() function:

function (message) {
  message=message.replace(/\r/g,'');
  message=message.replace(/\n/g,"__N__");
  message=message.replace(/,/g,"__C__");
  message=message.replace(/=/g,"__E__");
  message=message.replace(/\+/g,"__PS__");
  message=message.replace(/&/g,"__A__");
  message=message.replace(/%/g,"__P__");
  return message;
}

And the unCleanMessage() function:

function (message) {
  message=message.replace(/__PS__/g,"+");
  message=message.replace(/__P__/g,"%");
  message=message.replace(/__A__/g,"&");
  message=message.replace(/__E__/g,"=");
  message=message.replace(/__C__/g,",");
  message=message.replace(/__N__/g,"<br />");
  return message;
}

Now take a look at what happens if you type in "=A=" for instance.. the two equal signs get replaced and so it gets encoded to "__E__A__E__". Which then promptly gets decoded to "__E&E__" as the middle part "__A__" happens to get replaced first. Oops laugh.png

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!