diff gpp/smiley/__init__.py @ 286:72fd300685d5

For #95. You can now make posts with no text in the body if you have attachments. And now if you create a new topic with an attachment, and the POST fails (say you forgot the topic title), we will now re-attach attachments. Also fixed a bug in the smiley code that would arise if it was asked to markup an empty string.
author Brian Neal <bgneal@gmail.com>
date Sat, 23 Oct 2010 20:19:46 +0000
parents 3a626c48e9ae
children
line wrap: on
line diff
--- a/gpp/smiley/__init__.py	Thu Oct 14 02:39:35 2010 +0000
+++ b/gpp/smiley/__init__.py	Sat Oct 23 20:19:46 2010 +0000
@@ -22,6 +22,9 @@
         Converts and returns the supplied text with the HTML version of the
         smileys.
         """
+        if not value:
+            return u''
+
         if not autoescape or isinstance(value, SafeData):
             esc = lambda x: x
         else:
@@ -49,6 +52,9 @@
         Returns a string copy of the input s that has the smiley codes replaced
         with Markdown for smiley images.
         """
+        if not s:
+            return u''
+
         for regex, repl in self.regexes:
             s = regex.sub(repl, s)
         return s