From 8d31216103e6631b8f835cb497f83e2b0194f829 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Mon, 27 Jul 2026 19:01:19 +0530 Subject: [PATCH] fix: support Android SAX parsers --- .github/workflows/release.yml | 73 +++++++++++++++++++ jitpack.yml | 1 + .../internal/xml/parsing/SimpleSax.java | 12 ++- 3 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 jitpack.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..889d42a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,73 @@ +name: Release + +on: + workflow_dispatch: + +jobs: + release: + name: Create release + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.version.outputs.nextStrict }} + + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + fetch-depth: 0 + + - name: Get next version + id: version + uses: ietf-tools/semver-action@c90370b2958652d71c06a3484129a4d423a6d8a8 + with: + token: ${{ github.token }} + branch: ${{ github.event.repository.default_branch }} + noNewCommitBehavior: "warn" + noVersionBumpBehavior: "warn" + patchList: fix, bugfix, perf, refactor, test, tests, chore, build + + - name: Create and push tag + if: ${{ steps.version.outputs.nextStrict }} + run: | + set -euo pipefail + git config user.name "fossifybot[bot]" + git config user.email "212866877+fossifybot[bot]@users.noreply.github.com" + new_version="${{ steps.version.outputs.nextStrict }}" + echo "Creating tag: $new_version" + git tag -a "$new_version" -m "$new_version" + git push origin "$new_version" + echo "Created and pushed tag: $new_version" + + trigger_jitpack: + needs: release + runs-on: ubuntu-latest + if: ${{ needs.release.outputs.tag }} + steps: + - name: Trigger JitPack build + run: | + TAG='${{ needs.release.outputs.tag }}' + echo "Requesting JitPack build for ${TAG}" + curl -fsSL --max-time 180 "https://jitpack.io/org/fossify/java-mammoth/${TAG}/java-mammoth-${TAG}.pom" || true + + - name: Wait for JitPack to finish + run: | + TAG='${{ needs.release.outputs.tag }}' + URL="https://jitpack.io/org/fossify/java-mammoth/${TAG}/java-mammoth-${TAG}.pom" + + echo "Waiting for JitPack to build ${TAG}..." + sleep 240 + for i in $(seq 1 13); do + echo "Attempt $i: checking ${URL}?check=${i}" + if curl -fsSIL --max-time 300 "${URL}?check=${i}" > /dev/null 2>&1; then + echo "JitPack build successful!" + exit 0 + fi + + sleep 60 + done + + echo "Timed out waiting for JitPack build." + exit 1 diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..bb8a4f6 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1 @@ +jdk: openjdk17 diff --git a/src/main/java/org/zwobble/mammoth/internal/xml/parsing/SimpleSax.java b/src/main/java/org/zwobble/mammoth/internal/xml/parsing/SimpleSax.java index 0f444ba..b06de8d 100644 --- a/src/main/java/org/zwobble/mammoth/internal/xml/parsing/SimpleSax.java +++ b/src/main/java/org/zwobble/mammoth/internal/xml/parsing/SimpleSax.java @@ -3,6 +3,8 @@ import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.zwobble.mammoth.internal.util.PassThroughException; @@ -33,8 +35,14 @@ private static void parseInputSource(InputSource inputSource, SimpleSaxHandler h parserFactory.setNamespaceAware(true); try { parserFactory.setFeature("http://xml.org/sax/features/external-general-entities", false); - parserFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - parserFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + try { + parserFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); + } catch (SAXNotRecognizedException | SAXNotSupportedException ignored) { + } + try { + parserFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + } catch (SAXNotRecognizedException | SAXNotSupportedException ignored) { + } SAXParser saxParser = parserFactory.newSAXParser(); XMLReader xmlReader = saxParser.getXMLReader(); xmlReader.setContentHandler(new DefaultHandler() {