Skip to content

Commit

Permalink
Allow for passing in a JXE hardened SAX parser factory explicitly.
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Sep 1, 2024
1 parent 8d8a059 commit 4b7e95b
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 21 deletions.
7 changes: 6 additions & 1 deletion README-CHANGES.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<c:change date="2024-05-10T00:00:00+00:00" summary="Update com.io7m.blackthorne.version:2.0.0 → 2.0.1."/>
</c:changes>
</c:release>
<c:release date="2024-09-01T10:28:42+00:00" is-open="false" ticket-system="com.github.io7m.trasco" version="2.0.1">
<c:release date="2024-09-01T00:00:00+00:00" is-open="false" ticket-system="com.github.io7m.trasco" version="2.0.1">
<c:changes>
<c:change date="2024-05-27T00:00:00+00:00" summary="Update jqwik.version:1.8.4 → 1.8.5."/>
<c:change date="2024-06-28T00:00:00+00:00" summary="Update junit.version:5.10.2 → 5.10.3."/>
Expand All @@ -49,6 +49,11 @@
<c:change date="2024-09-01T00:00:00+00:00" summary="Only require JDK 17."/>
</c:changes>
</c:release>
<c:release date="2024-09-01T11:44:44+00:00" is-open="true" ticket-system="com.github.io7m.trasco" version="3.0.0">
<c:changes>
<c:change compatible="false" date="2024-09-01T11:44:44+00:00" summary="Allow for passing in a JXE hardened SAX parser factory explicitly."/>
</c:changes>
</c:release>
</c:releases>
<c:ticket-systems>
<c:ticket-system default="true" id="com.github.io7m.trasco" url="https://www.github.com/io7m-com/trasco/issues/"/>
Expand Down
6 changes: 5 additions & 1 deletion com.io7m.trasco.api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.trasco</artifactId>
<groupId>com.io7m.trasco</groupId>
<version>2.0.2-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>com.io7m.trasco.api</artifactId>
Expand Down Expand Up @@ -38,6 +38,10 @@
<groupId>com.io7m.anethum</groupId>
<artifactId>com.io7m.anethum.api</artifactId>
</dependency>
<dependency>
<groupId>com.io7m.jxe</groupId>
<artifactId>com.io7m.jxe.core</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
package com.io7m.trasco.api;

import com.io7m.anethum.api.ParserFactoryType;
import com.io7m.jxe.core.JXEHardenedSAXParsers;

/**
* A factory of revision set parsers.
*/

public interface TrSchemaRevisionSetParserFactoryType
extends ParserFactoryType<Object, TrSchemaRevisionSet, TrSchemaRevisionSetParserType>
extends ParserFactoryType<JXEHardenedSAXParsers, TrSchemaRevisionSet, TrSchemaRevisionSetParserType>
{

}
7 changes: 4 additions & 3 deletions com.io7m.trasco.api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
requires static org.osgi.annotation.bundle;
requires static org.osgi.annotation.versioning;

requires transitive com.io7m.anethum.api;
requires transitive com.io7m.seltzer.api;
requires transitive java.sql;
requires com.io7m.anethum.api;
requires com.io7m.jxe.core;
requires com.io7m.seltzer.api;
requires java.sql;

exports com.io7m.trasco.api;
}
2 changes: 1 addition & 1 deletion com.io7m.trasco.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.trasco</artifactId>
<groupId>com.io7m.trasco</groupId>
<version>2.0.2-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>com.io7m.trasco.tests</artifactId>
Expand Down
3 changes: 2 additions & 1 deletion com.io7m.trasco.tests/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
requires org.junit.platform.engine;
requires org.junit.platform.launcher;

requires org.xerial.sqlitejdbc;
requires com.io7m.anethum.api;
requires com.io7m.trasco.api;
requires com.io7m.trasco.vanilla;
requires org.slf4j;
requires org.xerial.sqlitejdbc;

exports com.io7m.trasco.tests;
}
2 changes: 1 addition & 1 deletion com.io7m.trasco.vanilla/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.trasco</artifactId>
<groupId>com.io7m.trasco</groupId>
<version>2.0.2-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>com.io7m.trasco.vanilla</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.io7m.trasco.vanilla;

import com.io7m.anethum.api.ParseStatus;
import com.io7m.jxe.core.JXEHardenedSAXParsers;
import com.io7m.trasco.api.TrSchemaRevisionSetParserFactoryType;
import com.io7m.trasco.api.TrSchemaRevisionSetParserType;
import com.io7m.trasco.vanilla.internal.TrSchemaSetRevisionParser;
Expand Down Expand Up @@ -44,7 +45,7 @@ public TrSchemaRevisionSetParsers()

@Override
public TrSchemaRevisionSetParserType createParserWithContext(
final Object context,
final JXEHardenedSAXParsers context,
final URI source,
final InputStream stream,
final Consumer<ParseStatus> statusConsumer)
Expand All @@ -53,6 +54,11 @@ public TrSchemaRevisionSetParserType createParserWithContext(
Objects.requireNonNull(stream, "stream");
Objects.requireNonNull(statusConsumer, "statusConsumer");

return new TrSchemaSetRevisionParser(source, stream, statusConsumer);
return new TrSchemaSetRevisionParser(
Objects.requireNonNullElse(context, new JXEHardenedSAXParsers()),
source,
stream,
statusConsumer
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.io7m.blackthorne.core.BTParseError;
import com.io7m.blackthorne.core.BTPreserveLexical;
import com.io7m.blackthorne.jxe.BlackthorneJXE;
import com.io7m.jxe.core.JXEHardenedSAXParsers;
import com.io7m.jxe.core.JXEXInclude;
import com.io7m.trasco.api.TrSchemaRevisionSet;
import com.io7m.trasco.api.TrSchemaRevisionSetParserType;
import com.io7m.trasco.vanilla.internal.v1.TrV1SchemaDeclSetParser;
Expand All @@ -35,6 +37,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;

Expand All @@ -50,20 +53,25 @@ public final class TrSchemaSetRevisionParser
private final URI source;
private final InputStream stream;
private final Consumer<ParseStatus> statusConsumer;
private final JXEHardenedSAXParsers parsers;

/**
* A parser of revision sets.
*
* @param inParsers The SAX parser provider
* @param inSource The source
* @param inStream The stream
* @param inStatusConsumer A status consumer
* @param inSource The source
*/

public TrSchemaSetRevisionParser(
final JXEHardenedSAXParsers inParsers,
final URI inSource,
final InputStream inStream,
final Consumer<ParseStatus> inStatusConsumer)
{
this.parsers =
Objects.requireNonNull(inParsers, "inParsers");
this.source =
Objects.requireNonNull(inSource, "source");
this.stream =
Expand Down Expand Up @@ -96,7 +104,7 @@ public TrSchemaRevisionSet execute()
{
try {
final TrSchemaRevisionSet schemas =
BlackthorneJXE.parse(
BlackthorneJXE.parseAll(
this.source,
this.stream,
Map.ofEntries(
Expand All @@ -105,8 +113,11 @@ public TrSchemaRevisionSet execute()
TrV1SchemaDeclSetParser::new
)
),
TrSchemas.schemas(),
BTPreserveLexical.PRESERVE_LEXICAL_INFORMATION
this.parsers,
Optional.empty(),
JXEXInclude.XINCLUDE_DISABLED,
BTPreserveLexical.PRESERVE_LEXICAL_INFORMATION,
TrSchemas.schemas()
);

return schemas;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* SQL revision system (Vanilla implementation [internals])
*/

@Version("1.0.0")
@Version("2.0.0")
package com.io7m.trasco.vanilla.internal;

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

@Export
@Version("1.0.0")
@Version("2.0.0")
package com.io7m.trasco.vanilla;

import org.osgi.annotation.bundle.Export;
Expand Down
4 changes: 2 additions & 2 deletions com.io7m.trasco.vanilla/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
requires static org.osgi.annotation.bundle;
requires static org.osgi.annotation.versioning;

requires transitive com.io7m.trasco.api;

requires com.io7m.trasco.api;
requires com.io7m.trasco.xml.schemas;

requires com.io7m.anethum.api;
requires com.io7m.blackthorne.core;
requires com.io7m.blackthorne.jxe;
requires com.io7m.junreachable.core;
requires com.io7m.jxe.core;
requires java.sql;
requires org.apache.commons.text;
requires org.slf4j;

Expand Down
2 changes: 1 addition & 1 deletion com.io7m.trasco.xml.schemas/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.trasco</artifactId>
<groupId>com.io7m.trasco</groupId>
<version>2.0.2-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>com.io7m.trasco.xml.schemas</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>com.io7m.trasco</groupId>
<artifactId>com.io7m.trasco</artifactId>
<version>2.0.2-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>

<packaging>pom</packaging>
<name>com.io7m.trasco</name>
Expand Down

0 comments on commit 4b7e95b

Please sign in to comment.