Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report error on invalid XML catalog URI #1270

Merged
merged 1 commit into from
Aug 5, 2022

Conversation

JessicaJHee
Copy link
Contributor

Fixes #823

Signed-off-by: Jessica He jhe@redhat.com

@angelozerr
Copy link
Contributor

I dont remember if we can do that but what about if uri starts with http://

@@ -90,7 +90,8 @@ public enum XMLSchemaErrorCode implements IXMLErrorCode {
TargetNamespace_2("TargetNamespace.2"), //
SchemaLocation("SchemaLocation"), //
schema_reference_4("schema_reference.4"), //
src_element_3("src-element.3");
src_element_3("src-element.3"), //
catalog_uri("catalog_uri");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catalog_uri error is not an error coming from XML validation based on XSD. Please remove it and create a XMLCatalogErrorCode in the catalog extensions


for (CatalogEntry catalogEntry : CatalogUtils.getCatalogEntries(xmlDocument)) {
String path = CatalogUtils.getResolvedLocation(xmlDocument, catalogEntry);
if (!FilesUtils.isValidPath(FilesUtils.getPath(path)) && URIUtils.isFileResource(path)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, it means that CatalogUtils.getResolvedLocation returns a path with file:// scheme even if the original uri doesn't starts with file://

If it that could you add a comment here with this information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's correct

Copy link
Contributor

@angelozerr angelozerr Aug 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks,could you add a comment here with a sample too (uri="foo/bar.xsd" -> path=file://.....bar.xsd

Signed-off-by: Jessica He <jhe@redhat.com>
@angelozerr
Copy link
Contributor

It works like a charm:

image

Great job @JessicaJHee !

@angelozerr angelozerr merged commit 39eefb7 into eclipse-lemminx:main Aug 5, 2022
@JessicaJHee JessicaJHee deleted the issue823 branch August 8, 2022 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate uri of XML catalog
2 participants