From d10e504a98edbf6223c4bf736e09f21e0d0c28c7 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 28 Jan 2017 18:37:12 +0000 Subject: [PATCH] https://github.com/golang/go/issues/18834 --- README.md | 3 ++- marshal.go | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3b65238..66a2a8c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ This is a temporary repository that will be removed when the issues below are fixed in the core golang code. ## Issues -* [encoding/asn1: cannot marshal into a GeneralString](https://github.com/golang/go/issues/18832) \ No newline at end of file +* [encoding/asn1: cannot marshal into a GeneralString](https://github.com/golang/go/issues/18832) +* [encoding/asn1: cannot marshal into slice of strings and pass stringtype parameter tags to members](https://github.com/golang/go/issues/18834) \ No newline at end of file diff --git a/marshal.go b/marshal.go index 8616b54..83a0224 100644 --- a/marshal.go +++ b/marshal.go @@ -489,8 +489,11 @@ func makeBody(value reflect.Value, params fieldParameters) (e encoder, err error default: m := make([]encoder, l) + // Pass on the tags to the members but need to unset explicit switch and implicit value + params.explicit = false + params.tag = nil for i := 0; i < l; i++ { - m[i], err = makeField(v.Index(i), fp) + m[i], err = makeField(v.Index(i), params) if err != nil { return nil, err } @@ -569,7 +572,8 @@ func makeField(v reflect.Value, params fieldParameters) (e encoder, err error) { return nil, StructuralError{"explicit time type given to non-time member"} } - if params.stringType != 0 && tag != TagPrintableString { + // Updated to accept a slice of strings + if params.stringType != 0 && !(tag == TagPrintableString || (v.Kind() == reflect.Slice && tag == 16 && v.Type().Elem().Kind() == reflect.String)){ return nil, StructuralError{"explicit string type given to non-string member"} }