mitsuhiko/markupsafe — pull request #20 by bukzor (2013-12-12 21:03:06+00:00)
Title: idempotent unescape

I added a failing test. Note that the current implementation deletes the middle portion of the text.

```
======================================================================
FAIL: test_unescape (markupsafe.tests.MarkupTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/nail/home/buck/trees/theirs/markupsafe/markupsafe/tests.py", line 71, in test_unescape
Markup("jack & tavi are cooler than mike & russ").unescape()
AssertionError: jack russ

----------------------------------------------------------------------
Ran 13 tests in 0.181s
```

Altering the regex fixes this issue.
Secondarily, the current implemetation will delete anything that *looks* like an html entity but is not:

```
======================================================================
FAIL: test_unescape (markupsafe.tests.MarkupTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/nail/home/buck/trees/theirs/markupsafe/markupsafe/tests.py", line 78, in test_unescape
assert expected == once == twice, (once, twice)
AssertionError: (u'&foo;', u'')

----------------------------------------------------------------------
Ran 13 tests in 0.171s
```