http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11756
Revision: 11756 Author: xqt Date: 2013-07-14 09:56:49 +0000 (Sun, 14 Jul 2013) Log Message: ----------- fix for does_text_contain_section (pdate from rewrite r11755): - re.escape() before substituting blank/underscor with regex - remove escaping blanks
Modified Paths: -------------- trunk/pywikipedia/pywikibot/textlib.py
Modified: trunk/pywikipedia/pywikibot/textlib.py =================================================================== --- trunk/pywikipedia/pywikibot/textlib.py 2013-07-14 09:53:32 UTC (rev 11755) +++ trunk/pywikipedia/pywikibot/textlib.py 2013-07-14 09:56:49 UTC (rev 11756) @@ -1073,7 +1073,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)
pywikipedia-svn@lists.wikimedia.org