mirror of
https://github.com/miniflux/v2.git
synced 2025-07-27 17:28:38 +00:00
First commit
This commit is contained in:
commit
8ffb773f43
2121 changed files with 1118910 additions and 0 deletions
43
vendor/github.com/tdewolff/parse/html/util_test.go
generated
vendored
Normal file
43
vendor/github.com/tdewolff/parse/html/util_test.go
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
package html // import "github.com/tdewolff/parse/html"
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/tdewolff/test"
|
||||
)
|
||||
|
||||
func TestEscapeAttrVal(t *testing.T) {
|
||||
var escapeAttrValTests = []struct {
|
||||
attrVal string
|
||||
expected string
|
||||
}{
|
||||
{"xyz", "xyz"},
|
||||
{"", ""},
|
||||
{"x&z", "x&z"},
|
||||
{"x/z", "x/z"},
|
||||
{"x'z", "\"x'z\""},
|
||||
{"x\"z", "'x\"z'"},
|
||||
{"'x\"z'", "'x\"z'"},
|
||||
{"'x'\"'z'", "\"x'"'z\""},
|
||||
{"\"x"'"z\"", "'x\"'\"z'"},
|
||||
{"\"x'z\"", "\"x'z\""},
|
||||
{"'x"z'", "'x\"z'"},
|
||||
{"'x\">'", "'x\">'"},
|
||||
{"You're encouraged to log in; however, it's not mandatory. [o]", "\"You're encouraged to log in; however, it's not mandatory. [o]\""},
|
||||
{"a'b=\"\"", "'a'b=\"\"'"},
|
||||
{"x<z", "\"x<z\""},
|
||||
{"'x\"'\"z'", "'x\"'\"z'"},
|
||||
}
|
||||
var buf []byte
|
||||
for _, tt := range escapeAttrValTests {
|
||||
t.Run(tt.attrVal, func(t *testing.T) {
|
||||
b := []byte(tt.attrVal)
|
||||
orig := b
|
||||
if len(b) > 1 && (b[0] == '"' || b[0] == '\'') && b[0] == b[len(b)-1] {
|
||||
b = b[1 : len(b)-1]
|
||||
}
|
||||
val := EscapeAttrVal(&buf, orig, []byte(b))
|
||||
test.String(t, string(val), tt.expected)
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue