aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/xml/xml.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/xml/xml.go')
-rw-r--r--src/encoding/xml/xml.go25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go
index 73eedad290..6b8f2e7978 100644
--- a/src/encoding/xml/xml.go
+++ b/src/encoding/xml/xml.go
@@ -2045,16 +2045,27 @@ func procInst(param, s string) string {
// TODO: this parsing is somewhat lame and not exact.
// It works for all actual cases, though.
param = param + "="
- _, v, _ := strings.Cut(s, param)
- if v == "" {
- return ""
+ lenp := len(param)
+ i := 0
+ var sep byte
+ for i < len(s) {
+ sub := s[i:]
+ k := strings.Index(sub, param)
+ if k < 0 || lenp+k >= len(sub) {
+ return ""
+ }
+ i += lenp + k + 1
+ if c := sub[lenp+k]; c == '\'' || c == '"' {
+ sep = c
+ break
+ }
}
- if v[0] != '\'' && v[0] != '"' {
+ if sep == 0 {
return ""
}
- unquote, _, ok := strings.Cut(v[1:], v[:1])
- if !ok {
+ j := strings.IndexByte(s[i:], sep)
+ if j < 0 {
return ""
}
- return unquote
+ return s[i : i+j]
}