@@ -42,11 +42,6 @@ def apply(cls):
4242 return decorator
4343
4444
45- @handler (signals .pre_save )
46- def escape_markdown (sender , document ):
47- document .markdown = html .escape (document .markdown )
48-
49-
5045class ZipField (FileField ):
5146
5247 def __init__ (self , max_size = 0 , ** ks ):
@@ -172,7 +167,6 @@ def info(self):
172167 }
173168
174169
175- @escape_markdown .apply
176170class Homework (Document ):
177171
178172 homework_name = StringField (
@@ -263,26 +257,7 @@ class ProblemDescription(EmbeddedDocument):
263257 db_field = 'sampleOutput' ,
264258 )
265259
266- def escape (self ):
267- self .description , self .input , self .output , self .hint = (html .escape (
268- v or '' ) for v in (
269- self .description ,
270- self .input ,
271- self .output ,
272- self .hint ,
273- ))
274- _io = zip (self .sample_input , self .sample_output )
275- for i , (ip , op ) in enumerate (_io ):
276- self .sample_input [i ] = ip or html .escape (ip )
277- self .sample_output [i ] = op or html .escape (op )
278-
279-
280- @handler (signals .pre_save )
281- def problem_desc_escape (sender , document ):
282- document .description .escape ()
283-
284260
285- @problem_desc_escape .apply
286261class Problem (Document ):
287262
288263 class Visibility :
@@ -419,7 +394,6 @@ class Submission(Document):
419394 ip_addr = StringField (default = None , null = True )
420395
421396
422- @escape_markdown .apply
423397class Message (Document ):
424398 timestamp = DateTimeField (default = datetime .now )
425399 sender = StringField (max_length = 16 , required = True )
@@ -429,7 +403,6 @@ class Message(Document):
429403 markdown = StringField (max_length = 100000 , required = True )
430404
431405
432- @escape_markdown .apply
433406class Announcement (Document ):
434407 status = IntField (default = 0 , choices = [0 , 1 ]) # not delete / delete
435408 title = StringField (max_length = 64 , required = True )
@@ -442,7 +415,6 @@ class Announcement(Document):
442415 pinned = BooleanField (default = False )
443416
444417
445- @escape_markdown .apply
446418class PostThread (Document ):
447419 markdown = StringField (default = '' , required = True , max_length = 100000 )
448420 author = ReferenceField ('User' , db_field = 'author' )
0 commit comments