http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11755
Revision: 11755
Author: xqt
Date: 2013-07-14 09:53:32 +0000 (Sun, 14 Jul 2013)
Log Message:
-----------
fix for does_text_contain_section:
- re.escape() before substituting blank/underscor with regex
- remove escaping blanks
Modified Paths:
--------------
branches/rewrite/pywikibot/textlib.py
Modified: branches/rewrite/pywikibot/textlib.py
===================================================================
--- branches/rewrite/pywikibot/textlib.py 2013-07-14 09:20:56 UTC (rev 11754)
+++ branches/rewrite/pywikibot/textlib.py 2013-07-14 09:53:32 UTC (rev 11755)
@@ -1089,7 +1089,7 @@
#----------------------------------
def does_text_contain_section(pagetext, section):
- section = re.sub('[ _]', '[ _]', section)
+ section = re.sub(r'\\[ _]', '[ _]', re.escape(section))
"""Determines whether the page text contains the given section
title."""
m = re.search("=+[ ']*%s[ ']*=+" % section, pagetext)
return bool(m)