Saturday, January 01, 2011
What? Not another 365 days …
HAPPY NEW YEAR!
Even though we still don't have flying cars, and we never did go back to Jupiter (heck, we never got there in the first place), maybe, just maybe, things will improve in 2011.
And remember, only 721 or 723 days left until The End Of the World As We Know It (but I feel fine).
(This post brought to you by EPS. Had this been an actual post, it most likely would have been exceedingly late)
Code and Data, Theory and Practice
- From
- Steve Crane <XXXXXXXXXXXXXXXXXXXXX>
- To
- Sean Conner <sean@conman.org>
- Subject
- @siwisdom twitter feed
- Date
- Sat, 1 Jan 2011 15:46:14 +0200
Hi Sean,
Are you aware that the quotation marks in the @siwisdom <http://twitter.com/siwisdom> tweets display as
“
and”
in clients like TweetDeck? Perhaps you should switch to using regular ASCII double quotes.Regards and Happy New Year.
Yes, I'm aware. They show up on the main Twitter page as well, and there isn't much I can do about it, other than sticking exclusively with ASCII and forgoing the nice typographic characters. It appears to be related to this rabbit hole, only in a way that's completely different.
What's going on here is explained here:
We have to encode HTML entities to prevent XSS attacks. Sorry about the lost characters.
counting messages: characters vs. bytes, HTML entities - Twitter Development Talk | Google Groups
And XSS has nothing to do with attacking one website from another, but everything to do with the proliferation of character encoding schemes and the desire to fling bits of executable code (aka ``Javascript'') along with our bits of non-exectuable data (aka ``HTML''). The problem is keeping the bits of executable code (aka ``Javascript'') from showing up where it isn't expected.
But in the case of Twitter, I don't think they actually understand how their own stack works. Or they just took the easy way out and any of the ``special'' characters in HTML, like ``&'', ``<'' and ``>'' are automatically converted to their HTML entity equivelents ``&'', ``<'' and ``>''. Otherwise, to sanitize the input, they would need to do the following:
- get the raw input from the HTML form
- convert the input from the transport encoding (usually URL encoding but it could be something else, depending upon the form)
- possibly convert the string into a workable character set the program understands (say, the browser sent the character data in WINDOWS-1251, because Microsoft is like that, to something a bit easier to work with, say, UTF-8)
- if HTML is allowed,
sanitize the HTML by
- removing unsupported or dangerous tags, like
<SCRIPT>
,<EMBED>
and<OBJECT>
- removing dangerous attributes like
STYLE
orONMOUSEOVER
- check
remaining attributes (like
HREF
) for dangerous content (likejavascript:alert('1 h@v3 h@cxx0r3d ur c0mput3r!!!!!!!11111')
)
- removing unsupported or dangerous tags, like
- escape the data to work with it properly (or else face the wrath of Little Bobby Tables' mother).
Fail to do any of those steps, and well … “1 h@v3 h@cxx0r3d ur c0mput3r!!!!!!!11111” And besides, I'm probably missing some sanitizing step somewhere.
Now, I could convert the input I give to Twitter to UTF-8 and avoid HTML entities entirely, but then I would have to convert my blog engine to UTF-8 (because I display my Twitter feed in the sidebar) and while it may work just fine with UTF-8, I haven't tested it with UTF-8 data. And I would prefer to keep it in US-ASCII to avoid any nasty surprises.
Besides, I shouldn't have to do this, because that's why HTML entities were designed in the first place—as a way of presenting characters when a character set doesn't support those characters!
Hey—wait a second … what 's this river doing here?