Bug 195840 - Import a XML file with BOM character in ant editor fails
Summary: Import a XML file with BOM character in ant editor fails
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M1   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-07-09 11:11 EDT by Jochen Stiepel CLA
Modified: 2008-07-15 16:29 EDT (History)
2 users (show)

See Also:


Attachments
file to be imported (145 bytes, text/xml)
2007-07-09 11:12 EDT, Jochen Stiepel CLA
no flags Details
file to be imported with BOM charater (148 bytes, text/xml)
2007-07-09 11:13 EDT, Jochen Stiepel CLA
no flags Details
this file has the import statement (222 bytes, text/xml)
2007-07-09 11:13 EDT, Jochen Stiepel CLA
no flags Details
patch (4.73 KB, patch)
2008-05-13 08:00 EDT, Martin Karpisek CLA
Michael_Rennie: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jochen Stiepel CLA 2007-07-09 11:11:10 EDT
Build ID: I20070621-1340

Steps To Reproduce:
If the ant build file to be imported (build.xml) has a Byte Order Mark (BOM) (example build_BOM.xml) as it's first character than the import in the second file (build-dist.xml) fails.

Import file "build_BOM.xml" in the "build-dist.xml" gives this errors:
- Content is not allowed in prolog.    Test    build-dist.xml    line 1
- Target build does not exist in this project    Test    build-dist.xml    line 5

Change the import statement to "build.xml" and the errors are gone.

The only difference is that build_BOM.xml includes a BOM character (eclipse shows it in the properties of a file, but not in the editor.

Eclipse 3.3, Java 1.6, Windows XP

More information:
Comment 1 Jochen Stiepel CLA 2007-07-09 11:12:18 EDT
Created attachment 73334 [details]
file to be imported
Comment 2 Jochen Stiepel CLA 2007-07-09 11:13:03 EDT
Created attachment 73335 [details]
file to be imported with BOM charater
Comment 3 Jochen Stiepel CLA 2007-07-09 11:13:40 EDT
Created attachment 73336 [details]
this file has the import statement
Comment 4 Darin Swanson CLA 2007-07-12 14:06:57 EDT
Thank you for the bug report.
I can reproduce and will investigate.
Comment 5 Darin Swanson CLA 2007-07-12 14:08:51 EDT
A zipped BOM file is available for testing in bug 61564.
Comment 6 Martin Karpisek CLA 2008-05-13 08:00:09 EDT
Created attachment 99927 [details]
patch

problem:
parser in ProjectHelper#parse throws SAXParseException when imported file (with byte order mark) is read by FileReader passed to InputSource

reason:
javadoc http://java.sun.com/j2se/1.4.2/docs/api/org/xml/sax/InputSource.html#InputSource(java.io.Reader) states: "The character stream shall not include a byte order mark."

solution (in this patch):
use file input stream instead of file reader
patch includes test case for org.eclipse.ant.tests.ui

link:
http://unicode.org/faq/utf_bom.html#BOM
Comment 7 Darin Swanson CLA 2008-05-13 11:26:35 EDT
Thanks Martin. I will review.
Comment 8 Philipe Mulet CLA 2008-05-23 04:29:50 EDT
Please adjust the target milestone, so it does not point at a closed milestone in the past.
Comment 9 Darin Swanson CLA 2008-07-01 17:10:25 EDT
Martin's fix has been released but from my testing only works on VMs newer than 1.4.* therefore I tweaked the new test to only run on 1.5 or newer.

Changes to:
ProjectHelper to use input streams instead of readers
AntEditorTests: add new test for this problem on 1.5 or newer
ProjectCreationDecorator: add ability to check if 1.5 or newer and close welcome intro

Added 2 test files:
importWithByteOrderMark.xml and toBeImportedWithByteOrderMark.xml
Comment 10 Darin Swanson CLA 2008-07-01 17:10:51 EDT
Please verify Michael.
Comment 11 Martin Karpisek CLA 2008-07-03 15:11:22 EDT
Thank you darin for using my fix, i hope it helped a little bit
Comment 12 Michael Rennie CLA 2008-07-15 16:29:28 EDT
verified