compiler: Compiler error when Link is set and Tooltip is an URL
This commit is contained in:
parent
1250ad3ea7
commit
bb54d03033
8 changed files with 6 additions and 7 deletions
|
|
@ -4,6 +4,6 @@
|
|||
|
||||
#### Improvements 🧹
|
||||
|
||||
- prevent `tooltip` to be an URL when `link` is already set. [#888](https://github.com/terrastruct/d2/pull/1091)
|
||||
- prevent `tooltip` to be an URL when `link` is already set. [#1091](https://github.com/terrastruct/d2/pull/1091)
|
||||
|
||||
#### Bugfixes ⛑️
|
||||
|
|
|
|||
|
|
@ -367,10 +367,9 @@ func (c *compiler) compileReserved(attrs *d2graph.Attributes, f *d2ir.Field) {
|
|||
if attrs.Link != nil && attrs.Tooltip != nil {
|
||||
_, err := url.ParseRequestURI(attrs.Tooltip.Value)
|
||||
if err == nil {
|
||||
c.errorf(scalar, "Tooltip cannot be an URL when Link is set")
|
||||
c.errorf(scalar, "Tooltip cannot be set to URL when link is also set (for security)")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (c *compiler) compileStyle(attrs *d2graph.Attributes, m *d2ir.Map) {
|
||||
|
|
|
|||
|
|
@ -1473,7 +1473,7 @@ x -> y: {
|
|||
{
|
||||
name: "no_url_link_and_url_tooltip_concurrently",
|
||||
text: `x: {link: https://not-google.com; tooltip: https://google.com}`,
|
||||
expErr: `d2/testdata/d2compiler/TestCompile/no_url_link_and_url_tooltip_concurrently.d2:1:44: Tooltip cannot be an URL when Link is set`,
|
||||
expErr: `d2/testdata/d2compiler/TestCompile/no_url_link_and_url_tooltip_concurrently.d2:1:44: Tooltip cannot be set to URL when link is also set (for security)`,
|
||||
},
|
||||
{
|
||||
name: "url_link_and_not_url_tooltip_concurrently",
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 285 KiB After Width: | Height: | Size: 285 KiB |
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 276 KiB After Width: | Height: | Size: 276 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Binary file not shown.
2
testdata/d2compiler/TestCompile/no_url_link_and_url_tooltip_concurrently.exp.json
generated
vendored
2
testdata/d2compiler/TestCompile/no_url_link_and_url_tooltip_concurrently.exp.json
generated
vendored
|
|
@ -5,7 +5,7 @@
|
|||
"errs": [
|
||||
{
|
||||
"range": "d2/testdata/d2compiler/TestCompile/no_url_link_and_url_tooltip_concurrently.d2,0:43:43-0:61:61",
|
||||
"errmsg": "d2/testdata/d2compiler/TestCompile/no_url_link_and_url_tooltip_concurrently.d2:1:44: Tooltip cannot be an URL when Link is set"
|
||||
"errmsg": "d2/testdata/d2compiler/TestCompile/no_url_link_and_url_tooltip_concurrently.d2:1:44: Tooltip cannot be set to URL when link is also set (for security)"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue