Skip to content

Commit 98471cc

Browse files
author
Arthur
committed
safeguard image generation width to 4096 pixels unless max width is provided
1 parent 8531576 commit 98471cc

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

‎Source/HtmlRenderer.WPF/HtmlRender.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ private static Size MeasureHtmlByRestrictions(HtmlContainer htmlContainer, Size
338338
using (var mg = new GraphicsAdapter())
339339
{
340340
var sizeInt = HtmlRendererUtils.MeasureHtmlByRestrictions(mg, htmlContainer.HtmlContainerInt, Utils.Convert(minSize), Utils.Convert(maxSize));
341+
if (maxSize.Width < 1 && sizeInt.Width > 4096)
342+
sizeInt.Width = 4096;
341343
return Utils.ConvertRound(sizeInt);
342344
}
343345
}

‎Source/HtmlRenderer.WinForms/HtmlRender.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,8 @@ private static Size MeasureHtmlByRestrictions(HtmlContainer htmlContainer, Size
651651
using (var mg = new GraphicsAdapter(g, htmlContainer.UseGdiPlusTextRendering))
652652
{
653653
var sizeInt = HtmlRendererUtils.MeasureHtmlByRestrictions(mg, htmlContainer.HtmlContainerInt, Utils.Convert(minSize), Utils.Convert(maxSize));
654+
if (maxSize.Width < 1 && sizeInt.Width > 4096)
655+
sizeInt.Width = 4096;
654656
return Utils.ConvertRound(sizeInt);
655657
}
656658
}

0 commit comments

Comments
 (0)