Revision: 6610
Author:   cosoleto
Date:     2009-04-16 10:26:26 +0000 (Thu, 16 Apr 2009)

Log Message:
-----------
Removed a 'scrubxml' function incorrectly added to Site class from r6567. 
Changed mediawiki_message, instead.

Modified Paths:
--------------
    trunk/pywikipedia/wikipedia.py

Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py      2009-04-16 08:30:47 UTC (rev 6609)
+++ trunk/pywikipedia/wikipedia.py      2009-04-16 10:26:26 UTC (rev 6610)
@@ -4901,16 +4901,6 @@
                 # Token not found
                 output(u'WARNING: Token not found on %s. You will not be able 
to edit any page.' % self)
 
-    def scrubxml(self, xml):
-        """scrub the start of xml input, to make things work, even
-        when crap is inserted ahead of the actual xml data. 
-        (such as when php reports strict warnings)"""
-        start = xml.find('<?xml')
-        if start < 0:
-            # '<?xml' not found ? Should not happen.
-            return ""
-        return xml[start:]
-
     def mediawiki_message(self, key):
         """Return the MediaWiki message text for key "key" """
         # Allmessages is retrieved once for all per created Site object
@@ -4964,8 +4954,14 @@
                     # </messages>
                     if elementtree:
                         decode = xml.encode(self.encoding())
-                        clean = self.scrubxml(decode)
-                        tree = XML(clean)
+
+                        # Skip extraneous data such as PHP warning or extra
+                        # whitespaces added from some MediaWiki extensions
+                        xml_dcl_pos = decode.find('<?xml')
+                        if xml_dcl_pos > 0:
+                            decode = decode[xml_dcl_pos:]
+
+                        tree = XML(decode)
                         self._mediawiki_messages = 
_dict([(tag.get('name').lower(), tag.text)
                                 for tag in tree.getiterator('message')])
                     else:



_______________________________________________
Pywikipedia-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l

Reply via email to