-
-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: escape constant attribute Go strings (#725)
Co-authored-by: Robert Kolmos <robertkolmos@gmail.com>
- Loading branch information
1 parent
702c106
commit 89f216e
Showing
5 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div> | ||
<!-- valid go escape sequences --> | ||
<input pattern="\a"/> | ||
<input pattern="\b"/> | ||
<input pattern="\f"/> | ||
<input pattern="\n"/> | ||
<input pattern="\r"/> | ||
<input pattern="\t"/> | ||
<input pattern="\v"/> | ||
<input pattern="\\"/> | ||
<input pattern="\777"/> | ||
<input pattern="\xFF"/> | ||
<input pattern="\u00FF"/> | ||
<input pattern="\u00FF\u00FF\u00FF"/> | ||
<!-- invalid go escape sequences --> | ||
<input pattern="\s"/> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package testconstantattributeescaping | ||
|
||
import ( | ||
_ "embed" | ||
"testing" | ||
|
||
"github.com/a-h/templ/generator/htmldiff" | ||
) | ||
|
||
//go:embed expected.html | ||
var expected string | ||
|
||
func Test(t *testing.T) { | ||
component := BasicTemplate() | ||
|
||
diff, err := htmldiff.Diff(component, expected) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if diff != "" { | ||
t.Error(diff) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package testconstantattributeescaping | ||
|
||
templ BasicTemplate() { | ||
<div> | ||
<!-- valid go escape sequences --> | ||
<input pattern="\a"/> | ||
<input pattern="\b"/> | ||
<input pattern="\f"/> | ||
<input pattern="\n"/> | ||
<input pattern="\r"/> | ||
<input pattern="\t"/> | ||
<input pattern="\v"/> | ||
<input pattern="\\"/> | ||
<input pattern="\777"/> | ||
<input pattern="\xFF"/> | ||
<input pattern="\u00FF"/> | ||
<input pattern="\u00FF\u00FF\u00FF"/> | ||
<!-- invalid go escape sequences --> | ||
<input pattern="\s"/> | ||
</div> | ||
} |
34 changes: 34 additions & 0 deletions
34
generator/test-constant-attribute-escaping/template_templ.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.