소스 검색

fixes a bug making request hang

Damien ACCORSI 10 년 전
부모
커밋
e497659731
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,7 +407,13 @@ class Content(DeclarativeBase):
407 407
         :return: a list of LinkItem
408 408
         """
409 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 417
         for link in soup.findAll('a'):
412 418
             href = link.get('href')
413 419
             label = link.contents
@@ -474,6 +480,10 @@ class Content(DeclarativeBase):
474 480
 
475 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 489
 class ContentChecker(object):

+ 1 - 1
tracim/tracim/model/serializers.py 파일 보기

@@ -594,7 +594,7 @@ def serialize_content_for_search_result(content: Content, context: Context):
594 594
             type = content.type,
595 595
 
596 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 599
             created = data_container.created,
600 600
             label = data_container.label,