Filtering Special Characters Injected by Microsoft Word

Saturday, April 17th, 2010 | code, development, django, hacks, nerdery, python, tips

I have been having trouble with users pasting content directly from M$ Word into admin fields, so I set out to create some sort of filter that replaces these little terds with something more HTML friendly. Here’s what I came up with, efficiency aside:

http://gist.github.com/370004

Please fork and enhance if you find more of these evil demon characters anywhere.

I guess it should also be noted that this can be called from any model save method on fields that you wish to filter.

UPDATE:

Just use SmartyPants: http://pypi.python.org/pypi/smartypants/

Share The Wealth:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • Slashdot
  • StumbleUpon

Tags: , , , , ,

No comments yet.

Leave a comment