Fix external SVG loading with proxies (#802)

This commit is contained in:
Niklas von Hertzen 2017-12-11 20:51:20 +08:00
parent d87fef11a4
commit 50608e9cd4
6 changed files with 11 additions and 10 deletions

View File

@ -1,6 +1,9 @@
### Changelog ###
#### v1.0.0-alpha4 - TBD ####
* Fix logging option (#1302)
* Add support for rendering webgl canvas content (#646)
* Fix external SVG loading with proxies (#802)
#### v1.0.0-alpha3 - 9.12.2017 ####
* Disable `foreignObjectRendering` by default (#1295)

View File

@ -177,6 +177,7 @@ export class DocumentCloner {
backgroundColor: '#ffffff',
canvas: null,
imageTimeout: this.options.imageTimeout,
logging: this.options.logging,
proxy: this.options.proxy,
removeContainer: this.options.removeContainer,
scale: this.options.scale,

View File

@ -34,16 +34,8 @@ export default class ResourceLoader {
return src;
}
if (isSVG(src)) {
if (this.options.allowTaint === true || FEATURES.SUPPORT_SVG_DRAWING) {
return this.addImage(src, src, false);
}
} else {
if (
this.options.allowTaint === true ||
isInlineBase64Image(src) ||
this.isSameOrigin(src)
) {
if (!isSVG(src) || FEATURES.SUPPORT_SVG_DRAWING) {
if (this.options.allowTaint === true || isInlineImage(src) || this.isSameOrigin(src)) {
return this.addImage(src, src, false);
} else if (!this.isSameOrigin(src)) {
if (typeof this.options.proxy === 'string') {

View File

@ -65,6 +65,7 @@ const html2canvas = (element: HTMLElement, conf: ?Options): Promise<*> => {
async: true,
allowTaint: false,
imageTimeout: 15000,
logging: true,
proxy: null,
removeContainer: true,
foreignObjectRendering: false,

View File

@ -15,6 +15,9 @@
<h1>External image</h1>
<img src="http://localhost:8081/assets/image2.jpg" style="border:5px solid black;" />
<h1>External svg image</h1>
<img src="http://localhost:8081/assets/image.svg" style="border:5px solid black;" />
<h1>External image (using &lt;base&gt; href)</h1>
<img src="/assets/image_1.jpg" />
</body>

View File

@ -16,5 +16,6 @@
<body>
<h1>External image (CORS)</h1>
<img src="http://localhost:8081/cors/tests/assets/image2.jpg" />
<img src="http://localhost:8081/cors/tests/assets/image.svg" />
</body>
</html>