unescape img hrefs
This commit is contained in:
parent
c5b814b624
commit
0314a74eab
5 changed files with 113 additions and 10 deletions
51
e2etests/testdata/regression/query_param_escape/dagre/board.exp.json
generated
vendored
51
e2etests/testdata/regression/query_param_escape/dagre/board.exp.json
generated
vendored
|
|
@ -52,6 +52,57 @@
|
||||||
"labelPosition": "INSIDE_TOP_CENTER",
|
"labelPosition": "INSIDE_TOP_CENTER",
|
||||||
"zIndex": 0,
|
"zIndex": 0,
|
||||||
"level": 1
|
"level": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "with ampersand",
|
||||||
|
"type": "",
|
||||||
|
"pos": {
|
||||||
|
"x": 250,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"width": 220,
|
||||||
|
"height": 152,
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"borderRadius": 0,
|
||||||
|
"fill": "#F7F8FE",
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"shadow": false,
|
||||||
|
"3d": false,
|
||||||
|
"multiple": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"link": "",
|
||||||
|
"icon": {
|
||||||
|
"Scheme": "https",
|
||||||
|
"Opaque": "",
|
||||||
|
"User": null,
|
||||||
|
"Host": "icons.terrastruct.com",
|
||||||
|
"Path": "/aws/Networking & Content Delivery/Amazon-API-Gateway_Endpoint_light-bg.svg",
|
||||||
|
"RawPath": "",
|
||||||
|
"ForceQuery": false,
|
||||||
|
"RawQuery": "",
|
||||||
|
"Fragment": "",
|
||||||
|
"RawFragment": ""
|
||||||
|
},
|
||||||
|
"iconPosition": "INSIDE_MIDDLE_CENTER",
|
||||||
|
"blend": false,
|
||||||
|
"fields": null,
|
||||||
|
"methods": null,
|
||||||
|
"columns": null,
|
||||||
|
"label": "with ampersand",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#0A0F25",
|
||||||
|
"italic": false,
|
||||||
|
"bold": true,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 120,
|
||||||
|
"labelHeight": 26,
|
||||||
|
"labelPosition": "INSIDE_TOP_CENTER",
|
||||||
|
"zIndex": 0,
|
||||||
|
"level": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"connections": []
|
"connections": []
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
id="d2-svg"
|
id="d2-svg"
|
||||||
style="background: white;"
|
style="background: white;"
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
width="394" height="356" viewBox="-102 -102 394 356"><style type="text/css">
|
width="674" height="356" viewBox="-102 -102 674 356"><style type="text/css">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
.shape {
|
.shape {
|
||||||
shape-rendering: geometricPrecision;
|
shape-rendering: geometricPrecision;
|
||||||
|
|
@ -39,8 +39,8 @@ width="394" height="356" viewBox="-102 -102 394 356"><style type="text/css">
|
||||||
svgEl.setAttribute("height", height * ratio - 16);
|
svgEl.setAttribute("height", height * ratio - 16);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
]]></script><g id="my network"><g class="shape" ><rect x="0" y="0" width="190" height="152" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/infra/019-network.svg?fuga=1&hoge" x="63.000000" y="44.000000" width="64" height="64" /><text class="text-bold" x="95.000000" y="21.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">my network</text></g><mask id="3050687478" maskUnits="userSpaceOnUse" x="-100" y="-100" width="394" height="356">
|
]]></script><g id="my network"><g class="shape" ><rect x="0" y="0" width="190" height="152" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/infra/019-network.svg?fuga=1&hoge" x="63.000000" y="44.000000" width="64" height="64" /><text class="text-bold" x="95.000000" y="21.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">my network</text></g><g id="with ampersand"><g class="shape" ><rect x="250" y="0" width="220" height="152" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/aws/Networking%20&%20Content%20Delivery/Amazon-API-Gateway_Endpoint_light-bg.svg" x="328.000000" y="44.000000" width="64" height="64" /><text class="text-bold" x="360.000000" y="21.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">with ampersand</text></g><mask id="1054261257" maskUnits="userSpaceOnUse" x="-100" y="-100" width="674" height="356">
|
||||||
<rect x="-100" y="-100" width="394" height="356" fill="white"></rect>
|
<rect x="-100" y="-100" width="674" height="356" fill="white"></rect>
|
||||||
|
|
||||||
</mask><style type="text/css"><![CDATA[
|
</mask><style type="text/css"><![CDATA[
|
||||||
.text-bold {
|
.text-bold {
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 324 KiB After Width: | Height: | Size: 325 KiB |
51
e2etests/testdata/regression/query_param_escape/elk/board.exp.json
generated
vendored
51
e2etests/testdata/regression/query_param_escape/elk/board.exp.json
generated
vendored
|
|
@ -52,6 +52,57 @@
|
||||||
"labelPosition": "INSIDE_TOP_CENTER",
|
"labelPosition": "INSIDE_TOP_CENTER",
|
||||||
"zIndex": 0,
|
"zIndex": 0,
|
||||||
"level": 1
|
"level": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "with ampersand",
|
||||||
|
"type": "",
|
||||||
|
"pos": {
|
||||||
|
"x": 222,
|
||||||
|
"y": 12
|
||||||
|
},
|
||||||
|
"width": 220,
|
||||||
|
"height": 152,
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"borderRadius": 0,
|
||||||
|
"fill": "#F7F8FE",
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"shadow": false,
|
||||||
|
"3d": false,
|
||||||
|
"multiple": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"link": "",
|
||||||
|
"icon": {
|
||||||
|
"Scheme": "https",
|
||||||
|
"Opaque": "",
|
||||||
|
"User": null,
|
||||||
|
"Host": "icons.terrastruct.com",
|
||||||
|
"Path": "/aws/Networking & Content Delivery/Amazon-API-Gateway_Endpoint_light-bg.svg",
|
||||||
|
"RawPath": "",
|
||||||
|
"ForceQuery": false,
|
||||||
|
"RawQuery": "",
|
||||||
|
"Fragment": "",
|
||||||
|
"RawFragment": ""
|
||||||
|
},
|
||||||
|
"iconPosition": "INSIDE_MIDDLE_CENTER",
|
||||||
|
"blend": false,
|
||||||
|
"fields": null,
|
||||||
|
"methods": null,
|
||||||
|
"columns": null,
|
||||||
|
"label": "with ampersand",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#0A0F25",
|
||||||
|
"italic": false,
|
||||||
|
"bold": true,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 120,
|
||||||
|
"labelHeight": 26,
|
||||||
|
"labelPosition": "INSIDE_TOP_CENTER",
|
||||||
|
"zIndex": 0,
|
||||||
|
"level": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"connections": []
|
"connections": []
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
id="d2-svg"
|
id="d2-svg"
|
||||||
style="background: white;"
|
style="background: white;"
|
||||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
width="394" height="356" viewBox="-90 -90 394 356"><style type="text/css">
|
width="634" height="356" viewBox="-90 -90 634 356"><style type="text/css">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
.shape {
|
.shape {
|
||||||
shape-rendering: geometricPrecision;
|
shape-rendering: geometricPrecision;
|
||||||
|
|
@ -39,8 +39,8 @@ width="394" height="356" viewBox="-90 -90 394 356"><style type="text/css">
|
||||||
svgEl.setAttribute("height", height * ratio - 16);
|
svgEl.setAttribute("height", height * ratio - 16);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
]]></script><g id="my network"><g class="shape" ><rect x="12" y="12" width="190" height="152" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/infra/019-network.svg?fuga=1&hoge" x="75.000000" y="56.000000" width="64" height="64" /><text class="text-bold" x="107.000000" y="33.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">my network</text></g><mask id="2671818094" maskUnits="userSpaceOnUse" x="-100" y="-100" width="394" height="356">
|
]]></script><g id="my network"><g class="shape" ><rect x="12" y="12" width="190" height="152" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/infra/019-network.svg?fuga=1&hoge" x="75.000000" y="56.000000" width="64" height="64" /><text class="text-bold" x="107.000000" y="33.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">my network</text></g><g id="with ampersand"><g class="shape" ><rect x="222" y="12" width="220" height="152" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/aws/Networking%20&%20Content%20Delivery/Amazon-API-Gateway_Endpoint_light-bg.svg" x="300.000000" y="56.000000" width="64" height="64" /><text class="text-bold" x="332.000000" y="33.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">with ampersand</text></g><mask id="2491478855" maskUnits="userSpaceOnUse" x="-100" y="-100" width="634" height="356">
|
||||||
<rect x="-100" y="-100" width="394" height="356" fill="white"></rect>
|
<rect x="-100" y="-100" width="634" height="356" fill="white"></rect>
|
||||||
|
|
||||||
</mask><style type="text/css"><![CDATA[
|
</mask><style type="text/css"><![CDATA[
|
||||||
.text-bold {
|
.text-bold {
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 324 KiB After Width: | Height: | Size: 325 KiB |
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -66,7 +67,7 @@ func filterImageElements(imgs [][][]byte, isRemote bool) [][][]byte {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
u, err := url.Parse(href)
|
u, err := url.Parse(html.UnescapeString(href))
|
||||||
isRemoteImg := err == nil && strings.HasPrefix(u.Scheme, "http")
|
isRemoteImg := err == nil && strings.HasPrefix(u.Scheme, "http")
|
||||||
|
|
||||||
if isRemoteImg == isRemote {
|
if isRemoteImg == isRemote {
|
||||||
|
|
@ -147,9 +148,9 @@ func worker(ctx context.Context, href []byte, isRemote bool) ([]byte, error) {
|
||||||
var mimeType string
|
var mimeType string
|
||||||
var err error
|
var err error
|
||||||
if isRemote {
|
if isRemote {
|
||||||
buf, mimeType, err = httpGet(ctx, string(href))
|
buf, mimeType, err = httpGet(ctx, html.UnescapeString(string(href)))
|
||||||
} else {
|
} else {
|
||||||
buf, err = os.ReadFile(string(href))
|
buf, err = os.ReadFile(html.UnescapeString(string(href)))
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -194,7 +195,7 @@ func httpGet(ctx context.Context, href string) ([]byte, string, error) {
|
||||||
func sniffMimeType(href, buf []byte, isRemote bool) string {
|
func sniffMimeType(href, buf []byte, isRemote bool) string {
|
||||||
p := string(href)
|
p := string(href)
|
||||||
if isRemote {
|
if isRemote {
|
||||||
u, err := url.Parse(p)
|
u, err := url.Parse(html.UnescapeString(p))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p = ""
|
p = ""
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue