aboutsummaryrefslogtreecommitdiff
path: root/Mammoth
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-09-19 14:16:21 +0100
committerMichael Williamson <mike@zwobble.org>2025-09-19 14:16:36 +0100
commit5391908ab339c9431d3f87fe201cf75e7ceecec0 (patch)
tree39c9076737ee5a8687133cb4f8516485ea673222 /Mammoth
parentaf15ea0632707e4f0b2c765dbbbb3c3d997c1f9f (diff)
Update tests for disabling external file access by default
Diffstat (limited to 'Mammoth')
-rw-r--r--Mammoth/DocumentConverter.cs24
1 files changed, 15 insertions, 9 deletions
diff --git a/Mammoth/DocumentConverter.cs b/Mammoth/DocumentConverter.cs
index 4995e54..1866e87 100644
--- a/Mammoth/DocumentConverter.cs
+++ b/Mammoth/DocumentConverter.cs
@@ -31,34 +31,40 @@ namespace Mammoth {
public DocumentConverter DisableDefaultStyleMap() {
return new DocumentConverter(options.disableDefaultStyleMap());
}
-
+
public DocumentConverter DisableEmbeddedStyleMap() {
return new DocumentConverter(options.disableEmbeddedStyleMap());
}
-
- public DocumentConverter ImageConverter(Func<IImage, IDictionary<string, string>> imageConverter) {
+
+ public DocumentConverter EnableExternalFileAccess()
+ {
+ return new DocumentConverter(options.enableExternalFileAccess());
+ }
+
+ public DocumentConverter ImageConverter(Func<IImage, IDictionary<string, string>> imageConverter)
+ {
return new DocumentConverter(options.imageConverter(new ImageConverterShim(imageConverter)));
}
-
+
internal class ImageConverterShim : Mammoth.Couscous.org.zwobble.mammoth.images.ImageConverter__ImgElement {
private readonly Func<IImage, IDictionary<string, string>> func;
-
+
internal ImageConverterShim(Func<IImage, IDictionary<string, string>> func) {
this.func = func;
}
-
+
public Mammoth.Couscous.java.util.Map<string, string> convert(Mammoth.Couscous.org.zwobble.mammoth.images.Image image) {
return ToJava.DictionaryToMap(func(new Image(image)));
}
}
-
+
internal class Image : IImage {
private readonly Mammoth.Couscous.org.zwobble.mammoth.images.Image image;
-
+
internal Image(Mammoth.Couscous.org.zwobble.mammoth.images.Image image) {
this.image = image;
}
-
+
public string AltText { get { return image.getAltText().orElse(null); } }
public string ContentType { get { return image.getContentType(); } }
public Stream GetStream() { return image.getInputStream().Stream; }