Edgewall Software

Changeset 259 for trunk/markup/input.py


Ignore:
Timestamp:
Aug 29, 2006, 6:34:40 PM (17 years ago)
Author:
cmlenz
Message:
  • Fix bug in handling of undefined entities. Thanks to Arnar for reporting the issue on IRC.
  • Enable the XMLParser to handle HTML entities without requiring the declaration of a HTML document type.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/markup/input.py

    r257 r259  
    8181        parser.ProcessingInstructionHandler = self._handle_pi
    8282        parser.CommentHandler = self._handle_comment
     83
     84        # Tell Expat that we'll handle non-XML entities ourselves
     85        # (in _handle_other)
    8386        parser.DefaultHandler = self._handle_other
     87        parser.UseForeignDTD()
    8488
    8589        # Location reporting is only support in Python >= 2.4
     
    185189                self._enqueue(TEXT, text)
    186190            except KeyError:
    187                 lineno, offset = self._getpos()
    188                 raise expat.error("undefined entity %s: line %d, column %d" %
    189                                   (text, lineno, offset))
     191                filename, lineno, offset = self._getpos()
     192                error = expat.error('undefined entity "%s": line %d, column %d'
     193                                    % (text, lineno, offset))
     194                error.code = expat.errors.XML_ERROR_UNDEFINED_ENTITY
     195                error.lineno = lineno
     196                error.offset = offset
     197                raise error
    190198
    191199
Note: See TracChangeset for help on using the changeset viewer.