Forum archives » Regarding Stripcreator » Weird Slash-Thingy

MikeyG
March 12, 2004 10:30 AM

All of a sudden a bunch of backslashes are popping up in my older comics. Like so:

209040

Post #127532link

attitudechicka
March 12, 2004 6:11 PM

quote:
Edited: 2-03-04 2:16pm)

This seems to be a problem with edited comics. I honestly don't know why it happens, I just know it happens to edited comics. I call it ECD or Edited Comics Disease.

Post #127598link

Brad
March 13, 2004 12:01 AM

This is bizarre, I can't seem to get it to do this in tests. You're just editing the comic and those slashes appear?

Post #127704link

Ahri
March 13, 2004 9:30 AM

Post #127737link

Brad
March 13, 2004 2:01 PM

That would remove all slashes from the text, meaning nobody could use the slash character at all.

Post #127772link

DragonXero
March 13, 2004 2:17 PM

And that would suck.

Post #127773link

laughinginyourface
March 13, 2004 4:31 PM

Damn straight it would.

Post #127795link

Ahri
March 13, 2004 8:33 PM

Ah, you're partly mistaken there Brad! You're right that it would remove slashes altogether from unescaped strings, but if all strings are being escaped (perhaps even twice in your case) then that is not an issue. Allow me to attempt to diagnose the problem and offer a vague solution.

Here's what I think is currently happening, in an oversimplified form:

// We'll take a sample string
$string = "What? You'd better have a damn good excuse, Daniel.";

// And escape it
$string = addslashes( $string ); // $string is now essentially "What? You\'d better have a damn good excuse, Daniel."

// Let's escape it again for some odd reason
$string = addslashes( $string ); // $string is now "What? You\\\'d better have a damn good excuse, Daniel."
?>

As you may be able to see, addslashes() is named oddly, since it's actually escaping potentially harmful characters. Similarly stripslashes() isn't just meandering about deleting slashes, it's un-escaping characters (for output.) The first time addslashes() is used in the above example the only harmful character is the apostrophe, so it's escaped with a slash. The second time though both the slash and the apostrophe are deemed harmful, so both are escaped (slashes put in front of them both.) Note that a slash is escaped both because it could be used maliciously and because if it wasn't escaped then it would be lost upon use of stripslashes().

So somewhere along the lines you're escaping the string twice. I suggest that since it's (reportedly) only affecting editted comics that you need to stripslashes() the submitted strings in the editting script, before using mysql_escape_string() (or whatever database function you're using to sanitize your strings.) Note that my above example can be altered to use mysql_escape_string() instead of addslashes() with no difference to the resulting string as in this narrow example they perform the exact same job.

Without access to your code I can't make a better guess, so I hope that helps.

I reccomend that you try to stop the escaping occuring twice, rather than counter-acting it at output; prevention being better than cure and all that ;)

Post #127828link

Ahri
March 13, 2004 8:40 PM

Adendum: My tests didn't yeild the same results as MikeyG. So either he's adding the slashes himself (unlikely since it's a phenomenon observed by others) or you have some weird code to fix up :)

Oh for some opensource goodness.....

Post #127830link

Ahri
March 13, 2004 8:41 PM

Addendum: I do know how to spell 'addendum'. Oops.

Post #127832link

Brad
March 13, 2004 9:16 PM

Well, it's pretty clear that the text is getting addslashes() run on it twice. However, I can't get this to happen on any comics when I edit them so that makes it pretty hard to track the problem down. Is anyone else having this problem?

Post #127838link

KajunFirefly
March 14, 2004 4:11 AM

30663

No problems with mine.

Post #127855link

attitudechicka
March 14, 2004 7:16 AM

I observed it before with some comics that had appostrophes (and sometimes with commas) used. I checked through mine, but couldn't find any slashes, though I'm sure I had to deal with it at some point. The worst part is, I don't know how I fixed it.

Post #127860link

MikeyG
March 17, 2004 9:03 AM

Brad, I only seem to get it with old edited comics where there owuld be ab apostrophe or quotation marks. I am not even sure if it's ONLY edited comics, and it didn't happen right after I edited them. It took me browsing through my oldies last week to see these mad slashes.

Post #128324link

jes_lawson
March 19, 2004 5:51 AM

quote:
Brad, I only seem to get it with old edited comics where there owuld be ab apostrophe or quotation marks. I am not even sure if it's ONLY edited comics, and it didn't happen right after I edited them. It took me browsing through my oldies last week to see these mad slashes.

Sounds like a problem with the escape characters.

/comics/jes_lawson/108865/

Works fine for me.

Post #128611link

Forum archives » Regarding Stripcreator » Weird Slash-Thingy

stripcreator
Make a comic
Forums
featuring
diesel sweeties
jerkcity
exploding dog
goats
ko fight club
penny arcade
chopping block
also
Brad Sucks