I suspect a regular expression gone wild. (ETA: This commit looks like a likely culprit, but I’m not sure what’s going on that might cause that particular behavior.)
ETA2: Heh. Thought so.
bash$ python
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> control_chars = re.compile(‘[\x00-\x08\x0b\0xc\x0e-\x1f]‘)
>>> text=”This is some HTML with c’s in it.”
>>> control_chars.sub(″,text)
“This is some HTML with ’s in it.”
ETA3: um, unit tests. Use them. Do yourself a favor. Pushing a bug to production that takes under a minute to locate from static inspection of the code? Embarrassing.
ETA4: …though, in fairness, I can see how someone test-driving this code could easily have written a test that didn’t catch this particular mistake.
ETA3: um, unit tests. Use them. Do yourself a favor. …
We agree completely. We inherited this code from Reddit, and we’ve spent multiple days trying to strap a workable unit testing framework onto it. As is often the case when you write the code first, strapping unit testing on later is hard.
We’ve basically given up on unit tests in this code base, but we’d love to be shown to be idiots on this one. Please take this opportunity to show us up by writing some example unit tests around any of our recent commits. We have strapped Selenium tests on.
I suspect a regular expression gone wild. (ETA: This commit looks like a likely culprit, but I’m not sure what’s going on that might cause that particular behavior.)
ETA2: Heh. Thought so.
ETA3: um, unit tests. Use them. Do yourself a favor. Pushing a bug to production that takes under a minute to locate from static inspection of the code? Embarrassing.
ETA4: …though, in fairness, I can see how someone test-driving this code could easily have written a test that didn’t catch this particular mistake.
We agree completely. We inherited this code from Reddit, and we’ve spent multiple days trying to strap a workable unit testing framework onto it. As is often the case when you write the code first, strapping unit testing on later is hard.
We’ve basically given up on unit tests in this code base, but we’d love to be shown to be idiots on this one. Please take this opportunity to show us up by writing some example unit tests around any of our recent commits.
We have strapped Selenium tests on.
Code contributions are very very welcome.
As long as you’re fixing regressions, how ’bout the whole “comments no longer showing up in IE7” that Silasbarta made a post on a few weeks ago?
edit: Seems to be fixed, thanks!
The regular expression is wrong: It has the term “\0xc” in it, when it should have had the term “\x0c”
So, instead of excluding the control character corresponding to ascii “0c”, it excluded the letters “x” and “c”.
This post is brought to you by letter