Skip to content

Commit a4628af

Browse files
authored
fix: support Android SAX parsers (#1)
1 parent 227d04c commit a4628af

3 files changed

Lines changed: 84 additions & 2 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
name: Create release
9+
runs-on: ubuntu-latest
10+
outputs:
11+
tag: ${{ steps.version.outputs.nextStrict }}
12+
13+
permissions:
14+
contents: write
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Get next version
23+
id: version
24+
uses: ietf-tools/semver-action@c90370b2958652d71c06a3484129a4d423a6d8a8
25+
with:
26+
token: ${{ github.token }}
27+
branch: ${{ github.event.repository.default_branch }}
28+
noNewCommitBehavior: "warn"
29+
noVersionBumpBehavior: "warn"
30+
patchList: fix, bugfix, perf, refactor, test, tests, chore, build
31+
32+
- name: Create and push tag
33+
if: ${{ steps.version.outputs.nextStrict }}
34+
run: |
35+
set -euo pipefail
36+
git config user.name "fossifybot[bot]"
37+
git config user.email "212866877+fossifybot[bot]@users.noreply.github.com"
38+
new_version="${{ steps.version.outputs.nextStrict }}"
39+
echo "Creating tag: $new_version"
40+
git tag -a "$new_version" -m "$new_version"
41+
git push origin "$new_version"
42+
echo "Created and pushed tag: $new_version"
43+
44+
trigger_jitpack:
45+
needs: release
46+
runs-on: ubuntu-latest
47+
if: ${{ needs.release.outputs.tag }}
48+
steps:
49+
- name: Trigger JitPack build
50+
run: |
51+
TAG='${{ needs.release.outputs.tag }}'
52+
echo "Requesting JitPack build for ${TAG}"
53+
curl -fsSL --max-time 180 "https://jitpack.io/org/fossify/java-mammoth/${TAG}/java-mammoth-${TAG}.pom" || true
54+
55+
- name: Wait for JitPack to finish
56+
run: |
57+
TAG='${{ needs.release.outputs.tag }}'
58+
URL="https://jitpack.io/org/fossify/java-mammoth/${TAG}/java-mammoth-${TAG}.pom"
59+
60+
echo "Waiting for JitPack to build ${TAG}..."
61+
sleep 240
62+
for i in $(seq 1 13); do
63+
echo "Attempt $i: checking ${URL}?check=${i}"
64+
if curl -fsSIL --max-time 300 "${URL}?check=${i}" > /dev/null 2>&1; then
65+
echo "JitPack build successful!"
66+
exit 0
67+
fi
68+
69+
sleep 60
70+
done
71+
72+
echo "Timed out waiting for JitPack build."
73+
exit 1

‎jitpack.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jdk: openjdk17

‎src/main/java/org/zwobble/mammoth/internal/xml/parsing/SimpleSax.java‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import org.xml.sax.Attributes;
44
import org.xml.sax.InputSource;
55
import org.xml.sax.SAXException;
6+
import org.xml.sax.SAXNotRecognizedException;
7+
import org.xml.sax.SAXNotSupportedException;
68
import org.xml.sax.XMLReader;
79
import org.xml.sax.helpers.DefaultHandler;
810
import org.zwobble.mammoth.internal.util.PassThroughException;
@@ -33,8 +35,14 @@ private static void parseInputSource(InputSource inputSource, SimpleSaxHandler h
3335
parserFactory.setNamespaceAware(true);
3436
try {
3537
parserFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
36-
parserFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
37-
parserFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
38+
try {
39+
parserFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
40+
} catch (SAXNotRecognizedException | SAXNotSupportedException ignored) {
41+
}
42+
try {
43+
parserFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
44+
} catch (SAXNotRecognizedException | SAXNotSupportedException ignored) {
45+
}
3846
SAXParser saxParser = parserFactory.newSAXParser();
3947
XMLReader xmlReader = saxParser.getXMLReader();
4048
xmlReader.setContentHandler(new DefaultHandler() {

0 commit comments

Comments
 (0)