Merge lp:~wallyworld/bzr4j/less-strict-xml-parsing into lp:bzr4j

Proposed by Ian Booth
Status: Merged
Merged at revision: 46
Proposed branch: lp:~wallyworld/bzr4j/less-strict-xml-parsing
Merge into: lp:bzr4j
Diff against target: 11 lines (+1/-0)
1 file modified
modules/core/src/main/java/org/emergent/bzr4j/core/cli/BzrXmlResult.java (+1/-0)
To merge this branch: bzr merge lp:~wallyworld/bzr4j/less-strict-xml-parsing
Reviewer Review Type Date Requested Status
Patrick Woodworth Pending
Review via email: mp+35789@code.launchpad.net

Commit message

Make bzr xmlstatus parsing less strict to handle "bad" bzr xml output.

Description of the change

When the plugin gathers info on changes, it runs bzr xmlstatus
If the resulting xml (as output by bzr) has issues, the xerces parser throws an exception and the plugin operation aborts. eg

2010-09-17 17:55:29,197 [ 148235] WARN - e.xmloutput.XmlAbstractHandler - sax error
org.xml.sax.SAXParseException: The value of attribute "fid" associated with an element type "file" must not contain the '<' character.
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)

An example of some bad xml is:

<file fid="x_Mark_Shuttleworth_<email address hidden>_Fri_Jul_22_22:53:21_2005_21772.2">lib/lp/code/interfaces/branch.py</file>

This is actual bzr output. The problem is that the fid attribute contains a '<' character.

By telling the xml parser to be less strict, the above issue is ignored and the plugin works correctly. Without the fix, changed files are not highlighted and change indicators in the gutter margins do not stick after the file is saved.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/core/src/main/java/org/emergent/bzr4j/core/cli/BzrXmlResult.java'
2--- modules/core/src/main/java/org/emergent/bzr4j/core/cli/BzrXmlResult.java 2010-03-02 20:44:47 +0000
3+++ modules/core/src/main/java/org/emergent/bzr4j/core/cli/BzrXmlResult.java 2010-09-17 09:35:54 +0000
4@@ -39,6 +39,7 @@
5 static {
6 try {
7 sm_saxParserFactory.setFeature("http://apache.org/xml/features/allow-java-encodings",true);
8+ sm_saxParserFactory.setFeature("http://apache.org/xml/features/continue-after-fatal-error", true);
9 } catch (ParserConfigurationException e) {
10 e.printStackTrace();
11 } catch (SAXNotRecognizedException e) {

Subscribers

People subscribed via source and target branches