commit
b7d1c9b563
2 changed files with 6 additions and 4 deletions
|
|
@ -15,3 +15,4 @@
|
||||||
- Fixes tooltip/link attributes being ignored for `sql_table` and `class`. [#658](https://github.com/terrastruct/d2/pull/658)
|
- Fixes tooltip/link attributes being ignored for `sql_table` and `class`. [#658](https://github.com/terrastruct/d2/pull/658)
|
||||||
- Fixes arrowheads sometimes appearing broken with sketch on. [#656](https://github.com/terrastruct/d2/pull/656)
|
- Fixes arrowheads sometimes appearing broken with sketch on. [#656](https://github.com/terrastruct/d2/pull/656)
|
||||||
- Fixes code snippets not being tall enough with leading newlines. [#664](https://github.com/terrastruct/d2/pull/664)
|
- Fixes code snippets not being tall enough with leading newlines. [#664](https://github.com/terrastruct/d2/pull/664)
|
||||||
|
- Icon URLs that needed escaping (e.g. with ampersands) are handled correctly by CLI. [#666](https://github.com/terrastruct/d2/pull/666)
|
||||||
|
|
|
||||||
|
|
@ -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