Bug 258208 - XMLContentDescriber throws StringIndexOutOfBoundsException
Summary: XMLContentDescriber throws StringIndexOutOfBoundsException
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.5 M4   Edit
Assignee: Szymon Brandys CLA
QA Contact:
URL:
Whiteboard: hasPatch
Keywords:
Depends on:
Blocks: 258343
  Show dependency tree
 
Reported: 2008-12-09 19:19 EST by Nick Sandonato CLA
Modified: 2008-12-11 07:33 EST (History)
3 users (show)

See Also:


Attachments
Fix v01 (2.85 KB, patch)
2008-12-10 04:25 EST, Szymon Brandys CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Sandonato CLA 2008-12-09 19:19:33 EST
XMLContentDesriber#isCharsetValid is throwing a StringIndexOutOfBoundsException when the charset is an empty string.

This is invalidating the content type org.eclipse.core.runtime.xml, resulting in other XML files picking up the incorrect content type once an XML file with encoding="" is encountered.



Here's the Event Log:
Could not create content describer for org.eclipse.core.runtime.xml. Content type has been disabled.

java.lang.StringIndexOutOfBoundsException
at java.lang.String.charAt(String.java:415)
at org.eclipse.core.runtime.content.XMLContentDescriber.isCharsetValid(XMLContentDescriber.java:159)
at org.eclipse.core.runtime.content.XMLContentDescriber.internalDescribe(XMLContentDescriber.java:86)
at org.eclipse.core.runtime.content.XMLContentDescriber.describe(XMLContentDescriber.java:67)
at org.eclipse.core.internal.content.ContentType.describe(ContentType.java:161)
at org.eclipse.core.internal.content.ContentType.internalGetDescriptionFor(ContentType.java:458)
at org.eclipse.core.internal.content.ContentTypeCatalog.getDescriptionFor(ContentTypeCatalog.java:314)
at org.eclipse.core.internal.content.ContentTypeCatalog.getDescriptionFor(ContentTypeCatalog.java:318)
at org.eclipse.core.internal.content.ContentTypeMatcher.getDescriptionFor(ContentTypeMatcher.java:86)
at org.eclipse.core.internal.resources.ContentDescriptionManager.readDescription(ContentDescriptionManager.java:416)
at org.eclipse.core.internal.resources.ContentDescriptionManager.getDescriptionFor(ContentDescriptionManager.java:342)
at org.eclipse.core.internal.resources.File.getContentDescription(File.java:280)
at org.eclipse.ui.internal.ide.ContentTypeDecorator.decorate(ContentTypeDecorator.java:42)
at org.eclipse.ui.internal.decorators.LightweightDecoratorDefinition.decorate(LightweightDecoratorDefinition.java:269)
at org.eclipse.ui.internal.decorators.LightweightDecoratorManager$LightweightRunnable.run(LightweightDecoratorManager.java:72)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.ui.internal.decorators.LightweightDecoratorManager.decorate(LightweightDecoratorManager.java:356)
at org.eclipse.ui.internal.decorators.LightweightDecoratorManager.getDecorations(LightweightDecoratorManager.java:338)
at org.eclipse.ui.internal.decorators.DecorationScheduler$1.ensureResultCached(DecorationScheduler.java:374)
at org.eclipse.ui.internal.decorators.DecorationScheduler$1.run(DecorationScheduler.java:334)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 1 Szymon Brandys CLA 2008-12-10 04:16:19 EST
Thanks. There is a bug indeed.
Comment 2 Szymon Brandys CLA 2008-12-10 04:25:34 EST
Created attachment 120008 [details]
Fix v01
Comment 3 Nick Sandonato CLA 2008-12-10 14:37:08 EST
I'm upping the severity to Major as this can wreak havoc on a workspace with just one poorly-written XML file causing others to be misidentified.

This is causing a series of our junits to fail since the org.eclipse.core.runtime.xml content type is disabled after one of our malformed XML tests.

Can this be retargeted to 3.5M4?
Comment 4 Szymon Brandys CLA 2008-12-11 07:33:34 EST
Released to HEAD.