浏览代码

Merge pull request #19 from lebouquetin/master

Tracim 10 年前
父节点
当前提交
2072fd582e
共有 2 个文件被更改,包括 12 次插入2 次删除
  1. 11 1
      tracim/tracim/model/data.py
  2. 1 1
      tracim/tracim/model/serializers.py

+ 11 - 1
tracim/tracim/model/data.py 查看文件

407
         :return: a list of LinkItem
407
         :return: a list of LinkItem
408
         """
408
         """
409
         links = []
409
         links = []
410
-        soup = BeautifulSoup(self.description if not other_content else other_content)
410
+
411
+        soup = BeautifulSoup(
412
+            self.description if not other_content else other_content,
413
+            'html.parser'  # Fixes hanging bug - http://stackoverflow.com/questions/12618567/problems-running-beautifulsoup4-within-apache-mod-python-django
414
+        )
415
+
416
+
411
         for link in soup.findAll('a'):
417
         for link in soup.findAll('a'):
412
             href = link.get('href')
418
             href = link.get('href')
413
             label = link.contents
419
             label = link.contents
474
 
480
 
475
         return None
481
         return None
476
 
482
 
483
+    def description_as_raw_text(self):
484
+        # 'html.parser' fixes a hanging bug
485
+        # see http://stackoverflow.com/questions/12618567/problems-running-beautifulsoup4-within-apache-mod-python-django
486
+        return BeautifulSoup(self.description, 'html.parser').text
477
 
487
 
478
 
488
 
479
 class ContentChecker(object):
489
 class ContentChecker(object):

+ 1 - 1
tracim/tracim/model/serializers.py 查看文件

594
             type = content.type,
594
             type = content.type,
595
 
595
 
596
             content = data_container.description,
596
             content = data_container.description,
597
-            content_raw = BeautifulSoup(data_container.description).text,
597
+            content_raw = data_container.description_as_raw_text(),
598
 
598
 
599
             created = data_container.created,
599
             created = data_container.created,
600
             label = data_container.label,
600
             label = data_container.label,