aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/xml/read.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/xml/read.go')
-rw-r--r--src/encoding/xml/read.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/encoding/xml/read.go b/src/encoding/xml/read.go
index a6fb665458..c2f495581a 100644
--- a/src/encoding/xml/read.go
+++ b/src/encoding/xml/read.go
@@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"reflect"
+ "runtime"
"strconv"
"strings"
)
@@ -308,14 +309,17 @@ var (
textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()
)
-const maxUnmarshalDepth = 10000
+const (
+ maxUnmarshalDepth = 10000
+ maxUnmarshalDepthWasm = 5000 // go.dev/issue/56498
+)
-var errExeceededMaxUnmarshalDepth = errors.New("exceeded max depth")
+var errUnmarshalDepth = errors.New("exceeded max depth")
// Unmarshal a single XML element into val.
func (d *Decoder) unmarshal(val reflect.Value, start *StartElement, depth int) error {
- if depth >= maxUnmarshalDepth {
- return errExeceededMaxUnmarshalDepth
+ if depth >= maxUnmarshalDepth || runtime.GOARCH == "wasm" && depth >= maxUnmarshalDepthWasm {
+ return errUnmarshalDepth
}
// Find start element if we need it.
if start == nil {