[Pywikipedia-l] [ pywikipediabot-Bugs-2169485 ] image.py bug

SourceForge.net noreply at sourceforge.net
Mon Oct 20 03:13:14 UTC 2008


Bugs item #2169485, was opened at 2008-10-15 22:56
Message generated for change (Comment added) made by nicdumz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2169485&group_id=93107

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: giurrero (giurrero)
Assigned to: Nobody/Anonymous (nobody)
Summary: image.py bug

Initial Comment:
image.py has a bug here:

if not site.nocapitalize:
            old = '[' + self.oldImage[0].upper() + self.oldImage[0].lower() + ']' + self.oldImage[1:]
        else:
            old = self.oldImage

        old = re.sub('[_ ]', '[_ ]', old)
        escaped = re.escape(old)
        if not self.loose or not self.newImage:
            ImageRegex = re.compile(r'\[\[ *(?:' + '|'.join(site.namespace(6, all = True)) + ')\s*:\s*' + escaped + ' *(?P<parameters>\|[^\n]+|) *\]\]')
        else:
            ImageRegex = re.compile(r'' + escaped)

the escaping must be the first thing that you do, now if you replace [_ ] with [_ ], and do the escaping:

"my_image" -> "my[ _]image" -> "my\[\ \_\]image"

I think that the solution in wikipedia.py replaceImage will be the best



Pywikipedia [http] trunk/pywikipedia (r5976, Oct 15 2008, 17:28:48)
Python 2.5.2 (r252:60911, Aug  1 2008, 00:37:21)
[GCC 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]]


----------------------------------------------------------------------

Comment By: NicDumZ  Nicolas Dumazet (nicdumz)
Date: 2008-10-20 05:13

Message:
And similarly, if not self.nocapitalize:
imageName -> [iI]mageName -> \[iI\]mageName

Proper fix committed in r6002, thanks for the report !!

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2169485&group_id=93107



More information about the Pywikipedia-l mailing list