Commits

cboos  committed 4e2222c

Ported [4126] to 0.10-stable (''WikiPageNames parsing performance issue'')

  • Participants
  • Parent commits fda1d90
  • Branches 0.10-stable

Comments (0)

Files changed (3)

File trac/wiki/api.py

 
     # IWikiSyntaxProvider methods
 
-    XML_NAME = r"[\w:](?<!\d)(?:[\w:.-]*?[\w:-])*"
-    # See http://www.w3.org/TR/REC-xml/#id, here adapted to exclude terminal "."
+    XML_NAME = r"[\w:](?<!\d)(?:[\w:.-]*[\w-])?"
+    # See http://www.w3.org/TR/REC-xml/#id,
+    # here adapted to exclude terminal "." and ":" characters
 
     def format_page_name(self, page):
         if self.split_page_names:
         wiki_page_name = (
             r"[A-Z][a-z]+(?:[A-Z][a-z]*[a-z/])+" # wiki words
             r"(?:#%s)?" % self.XML_NAME + # optional fragment id
-            r"(?=:?\Z|:?\s|[.,;!?\)}\'\"\]])" # what should follow it
+            r"(?=[^a-zA-Z]|\s|\Z)" # what should follow it
             )
         
         # Regular WikiPageNames

File trac/wiki/tests/wiki-tests.txt

 [[HelloWorld(hej hopp) ]] # This shouldnt executed as macro since it contain whitespace between ) and ]
 ------------------------------
 <p>
-[[HelloWorld(hej hopp) ]] # This shouldnt executed as macro since it contain whitespace between ) and ]
+[[<a class="missing wiki" href="/wiki/HelloWorld" rel="nofollow">HelloWorld?</a>(hej hopp) ]] # This shouldnt executed as macro since it contain whitespace between ) and ]
 </p>
 ------------------------------
-[[HelloWorld(hej hopp) ]] # This shouldnt executed as macro since it contain whitespace between ) and ]
+[[<a class="missing wiki" href="/wiki/HelloWorld" rel="nofollow">HelloWorld?</a>(hej hopp) ]] # This shouldnt executed as macro since it contain whitespace between ) and ]
 ============================== Another bad macro call
 [[HelloWorld(hej hopp))]] # Extra right brace and still executed
 ------------------------------

File trac/wiki/tests/wikisyntax.py

 <a class="missing wiki" href="/wiki/TracSubversion#TracandSubversion1.3.1" rel="nofollow">TracSubversion#TracandSubversion1.3.1?</a>. etc.
 </p>
 ------------------------------
+============================== WikiPageNames with fragment id (performance test)
+BillOfMaterials#get_bill_of_materials_from_room_xml(fpxml=nil)
+
+[BillOfMaterials#get_bill_of_materials_from_room_xml(fpxml=nil)]
+
+[BillOfMaterials#get_bill_of_materials_from_room_xml(fpxml=nil) speed]
+------------------------------
+<p>
+<a class="missing wiki" href="/wiki/BillOfMaterials#get_bill_of_materials_from_room_xml" rel="nofollow">BillOfMaterials#get_bill_of_materials_from_room_xml?</a>(fpxml=nil)
+</p>
+<p>
+[<a class="missing wiki" href="/wiki/BillOfMaterials#get_bill_of_materials_from_room_xml" rel="nofollow">BillOfMaterials#get_bill_of_materials_from_room_xml?</a>(fpxml=nil)]
+</p>
+<p>
+[<a class="missing wiki" href="/wiki/BillOfMaterials#get_bill_of_materials_from_room_xml" rel="nofollow">BillOfMaterials#get_bill_of_materials_from_room_xml?</a>(fpxml=nil) speed]
+</p>
+------------------------------
 ============================== WikiPageNames counter examples (paths)
 /absolute/path/is/NotWiki and relative/path/is/NotWiki
 /ThisIsNotWikiEither and /ThisIs/NotWikiEither but ThisIs/SubWiki