diff --git a/Gopkg.lock b/Gopkg.lock index a09f2aea3..c63e2c365 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -34,8 +34,8 @@ ".", "lang/go" ] - revision = "6a9d0d1ee28a34f19bd0ff2402126393651b5085" - version = "v0.4.2" + revision = "2a4874b2def53736ccf1f75fd48546c09c658959" + version = "v0.4.3" [[projects]] name = "github.com/spf13/afero" @@ -50,7 +50,7 @@ branch = "master" name = "golang.org/x/net" packages = ["context"] - revision = "26e67e76b6c3f6ce91f7c52def5af501b4e0f3a2" + revision = "9b4f9f5ad5197c79fd623a3638e70d8b26cef344" [[projects]] name = "golang.org/x/text" @@ -68,6 +68,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "30429e2d2aabdf549b83088f57af2023efae5f9c5a44adb1faa89d862d0ced23" + inputs-digest = "0703cad49c2817a552ee72bf928a608e883f77f65a04e60a8d61a882b2087482" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 63de0b54c..606422bb9 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -4,7 +4,7 @@ [[constraint]] name = "github.com/lyft/protoc-gen-star" - version = "0.4.2" + version = "0.4.3" [[constraint]] branch = "master" diff --git a/Makefile b/Makefile index 721430b70..ef8417103 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ vendor: .PHONY: lint lint: # lints the package for common code smells - which golint || go get -u github.com/golang/lint/golint + which golint || go get -u golang.org/x/lint/golint test -z "$(gofmt -d -s ./*.go)" || (gofmt -d -s ./*.go && exit 1) # golint -set_exit_status go tool vet -all -shadow -shadowstrict *.go diff --git a/templates/cc/register.go b/templates/cc/register.go index 74e569f17..ab08a079b 100644 --- a/templates/cc/register.go +++ b/templates/cc/register.go @@ -137,8 +137,15 @@ func (fns CCFuncs) hasAccessor(ctx shared.RuleContext) string { fns.methodName(ctx.Field.Name())) } +func (fns CCFuncs) classBaseName(msg pgs.Message) string { + if m, ok := msg.Parent().(pgs.Message); ok { + return fmt.Sprintf("%s_%s", fns.classBaseName(m), msg.Name().String()) + } + return msg.Name().String() +} + func (fns CCFuncs) className(msg pgs.Message) string { - return fns.packageName(msg) + "::" + fns.Name(msg).String() + return fns.packageName(msg) + "::" + fns.classBaseName(msg) } func (fns CCFuncs) packageName(msg pgs.Message) string { diff --git a/tests/harness/cases/messages.proto b/tests/harness/cases/messages.proto index 62bddc9c1..871344d1b 100644 --- a/tests/harness/cases/messages.proto +++ b/tests/harness/cases/messages.proto @@ -26,3 +26,5 @@ message Message { TestMsg val = 1; } message MessageCrossPackage { tests.harness.cases.other_package.Embed val = 1; } message MessageSkip { TestMsg val = 1 [(validate.rules).message.skip = true];} message MessageRequired { TestMsg val = 1 [(validate.rules).message.required = true]; } + +message MessageWith3dInside {} diff --git a/vendor/github.com/gogo/protobuf/proto/properties.go b/vendor/github.com/gogo/protobuf/proto/properties.go index 0e36a11dd..7a5e28efe 100644 --- a/vendor/github.com/gogo/protobuf/proto/properties.go +++ b/vendor/github.com/gogo/protobuf/proto/properties.go @@ -598,10 +598,3 @@ func RegisterFile(filename string, fileDescriptor []byte) { // FileDescriptor returns the compressed FileDescriptorProto for a .proto file. func FileDescriptor(filename string) []byte { return protoFiles[filename] } - -func EnumerateRegistered() { - log.Printf("ENUMERATING %d TYPES", len(protoTypedNils)) - for k, v := range protoTypedNils { - log.Printf("%s => %T", k, v) - } -} diff --git a/vendor/github.com/lyft/protoc-gen-star/.travis.yml b/vendor/github.com/lyft/protoc-gen-star/.travis.yml index 37fa3aea6..d3620c565 100644 --- a/vendor/github.com/lyft/protoc-gen-star/.travis.yml +++ b/vendor/github.com/lyft/protoc-gen-star/.travis.yml @@ -1,5 +1,6 @@ language: go go: "1.11" +go_import_path: github.com/lyft/protoc-gen-star env: global: diff --git a/vendor/github.com/lyft/protoc-gen-star/README.md b/vendor/github.com/lyft/protoc-gen-star/README.md index 3c58d2a43..c33c2ac00 100644 --- a/vendor/github.com/lyft/protoc-gen-star/README.md +++ b/vendor/github.com/lyft/protoc-gen-star/README.md @@ -304,7 +304,7 @@ For developing on PG*, you should install the package within the `GOPATH`. PG* u ```sh go get -u github.com/lyft/protoc-gen-star -cd $GOPATH/github.com/lyft/protoc-gen-star +cd $GOPATH/src/github.com/lyft/protoc-gen-star make vendor ``` diff --git a/vendor/github.com/lyft/protoc-gen-star/artifact.go b/vendor/github.com/lyft/protoc-gen-star/artifact.go index 91d4fa5e3..21bcd1bb8 100644 --- a/vendor/github.com/lyft/protoc-gen-star/artifact.go +++ b/vendor/github.com/lyft/protoc-gen-star/artifact.go @@ -310,3 +310,13 @@ func cleanGeneratorFileName(name string) (string, error) { return name, nil } + +// GeneratorError Artifacts are strings describing errors that happened in the +// code generation, but have not been fatal. They'll be used to populate the +// CodeGeneratorResponse's `error` field. Since that field is a string, multiple +// GeneratorError Artifacts will be concatenated. +type GeneratorError struct { + Artifact + + Message string +} diff --git a/vendor/github.com/lyft/protoc-gen-star/lang/go/name.go b/vendor/github.com/lyft/protoc-gen-star/lang/go/name.go index da6b96d51..4110781af 100644 --- a/vendor/github.com/lyft/protoc-gen-star/lang/go/name.go +++ b/vendor/github.com/lyft/protoc-gen-star/lang/go/name.go @@ -45,7 +45,21 @@ func (c context) Name(node pgs.Node) pgs.Name { } func (c context) OneofOption(field pgs.Field) pgs.Name { - return pgs.Name(joinNames(c.Name(field.Message()), c.Name(field))) + n := pgs.Name(joinNames(c.Name(field.Message()), c.Name(field))) + + for _, msg := range field.Message().Messages() { + if c.Name(msg) == n { + return n + "_" + } + } + + for _, en := range field.Message().Enums() { + if c.Name(en) == n { + return n + "_" + } + } + + return n } func (c context) ServerName(s pgs.Service) pgs.Name { diff --git a/vendor/github.com/lyft/protoc-gen-star/lang/go/name_test.go b/vendor/github.com/lyft/protoc-gen-star/lang/go/name_test.go index bb95f73ae..a5d95f96a 100644 --- a/vendor/github.com/lyft/protoc-gen-star/lang/go/name_test.go +++ b/vendor/github.com/lyft/protoc-gen-star/lang/go/name_test.go @@ -57,6 +57,8 @@ func TestName(t *testing.T) { {"_underscore", "XUnderscore"}, {"__DoubleUnderscore", "X_DoubleUnderscore"}, {"String", "String"}, + {"MsgWith3dInside", "MsgWith3DInside"}, + {"MsgEndsWith3d", "MsgEndsWith3D"}, // Nested Messages {"Nested.Message", "Nested_Message"}, @@ -159,6 +161,8 @@ func TestContext_OneofOption(t *testing.T) { {"lowerCamelCaseO", "Oneofs_LowerCamelCaseO"}, {"UpperCamelCaseO", "Oneofs_UpperCamelCaseO"}, {"reset", "Oneofs_Reset_"}, + {"some_msg", "Oneofs_SomeMsg_"}, + {"some_enum", "Oneofs_SomeEnum_"}, } for _, test := range tests { diff --git a/vendor/github.com/lyft/protoc-gen-star/lang/go/testdata/names/entities/entities.proto b/vendor/github.com/lyft/protoc-gen-star/lang/go/testdata/names/entities/entities.proto index c5c59f4d5..2c4728db6 100644 --- a/vendor/github.com/lyft/protoc-gen-star/lang/go/testdata/names/entities/entities.proto +++ b/vendor/github.com/lyft/protoc-gen-star/lang/go/testdata/names/entities/entities.proto @@ -88,6 +88,13 @@ message Oneofs { bool UpperCamelCaseO = 11; bool reset = 12; // protected } + + message SomeMsg {} + enum SomeEnum { VALUE = 0; } + oneof some_msg_oneof { + SomeMsg some_msg = 13; + SomeEnum some_enum = 14; + } } service UpperCamelService {} @@ -110,3 +117,8 @@ service Service { rpc SCREAMING_SNAKE(String) returns (String); rpc Reset(String) returns (String); } + +message MsgWith3dInside {} + +message MsgEndsWith3d {} + diff --git a/vendor/github.com/lyft/protoc-gen-star/lang/go/testdata/names/import_path_mapped/import_path_mapped.proto b/vendor/github.com/lyft/protoc-gen-star/lang/go/testdata/names/import_path_mapped/import_path_mapped.proto new file mode 100644 index 000000000..4b56a6924 --- /dev/null +++ b/vendor/github.com/lyft/protoc-gen-star/lang/go/testdata/names/import_path_mapped/import_path_mapped.proto @@ -0,0 +1,5 @@ +syntax="proto3"; +package names.import_path_mapped; +option go_package="go_package"; + +message Mapped {} diff --git a/vendor/github.com/lyft/protoc-gen-star/lang/go/testdata/names/import_path_mapped/params b/vendor/github.com/lyft/protoc-gen-star/lang/go/testdata/names/import_path_mapped/params new file mode 100644 index 000000000..dd7e2d473 --- /dev/null +++ b/vendor/github.com/lyft/protoc-gen-star/lang/go/testdata/names/import_path_mapped/params @@ -0,0 +1 @@ +Mnames/import_path_mapped/import_path_mapped.proto=github.com/foo/bar,import_path=github.com/fizz/buzz diff --git a/vendor/github.com/lyft/protoc-gen-star/module.go b/vendor/github.com/lyft/protoc-gen-star/module.go index 069cf2a62..528a8318a 100644 --- a/vendor/github.com/lyft/protoc-gen-star/module.go +++ b/vendor/github.com/lyft/protoc-gen-star/module.go @@ -256,4 +256,11 @@ func (m *ModuleBase) OverwriteCustomTemplateFile(name string, tpl Template, data }) } +// AddError adds a string to the `errors` field of the created +// CodeGeneratorResponse. Multiple calls to AddError will cause the errors to +// be concatenated (separated by "; "). +func (m *ModuleBase) AddError(message string) { + m.AddArtifact(GeneratorError{Message: message}) +} + var _ Module = (*ModuleBase)(nil) diff --git a/vendor/github.com/lyft/protoc-gen-star/module_test.go b/vendor/github.com/lyft/protoc-gen-star/module_test.go index a857ae14d..94eae59ae 100644 --- a/vendor/github.com/lyft/protoc-gen-star/module_test.go +++ b/vendor/github.com/lyft/protoc-gen-star/module_test.go @@ -272,3 +272,13 @@ func TestModuleBase_OverwriteCustomTemplateFile(t *testing.T) { }, }, arts[0]) } + +func TestModuleBase_AddError(t *testing.T) { + t.Parallel() + + m := new(ModuleBase) + m.AddError("bohoo") + arts := m.Artifacts() + assert.Len(t, arts, 1) + assert.Equal(t, GeneratorError{Message: "bohoo"}, arts[0]) +} diff --git a/vendor/github.com/lyft/protoc-gen-star/persister.go b/vendor/github.com/lyft/protoc-gen-star/persister.go index 94efb0c62..56335b75e 100644 --- a/vendor/github.com/lyft/protoc-gen-star/persister.go +++ b/vendor/github.com/lyft/protoc-gen-star/persister.go @@ -3,6 +3,7 @@ package pgs import ( "os" "path/filepath" + "strings" "github.com/golang/protobuf/proto" "github.com/golang/protobuf/protoc-gen-go/plugin" @@ -83,6 +84,12 @@ func (p *stdPersister) Persist(arts ...Artifact) *plugin_go.CodeGeneratorRespons a.Overwrite, a.Perms, ) + case GeneratorError: + if resp.Error == nil { + resp.Error = proto.String(a.Message) + continue + } + resp.Error = proto.String(strings.Join([]string{resp.GetError(), a.Message}, "; ")) default: p.Failf("unrecognized artifact type: %T", a) } diff --git a/vendor/github.com/lyft/protoc-gen-star/persister_test.go b/vendor/github.com/lyft/protoc-gen-star/persister_test.go index ca4da1658..3cb8e7fc2 100644 --- a/vendor/github.com/lyft/protoc-gen-star/persister_test.go +++ b/vendor/github.com/lyft/protoc-gen-star/persister_test.go @@ -315,3 +315,41 @@ func dummyPersister(d Debugger) *stdPersister { fs: afero.NewMemMapFs(), } } + +func TestPersister_Persist_GeneratorError(t *testing.T) { + t.Parallel() + + cases := map[string]struct { + input []Artifact + output string + }{ + "no errors": { + []Artifact{}, + "", + }, + "one error": { + []Artifact{GeneratorError{Message: "something went wrong"}}, + "something went wrong", + }, + "two errors": { + []Artifact{ + GeneratorError{Message: "something went wrong"}, + GeneratorError{Message: "something else went wrong, too"}, + }, + "something went wrong; something else went wrong, too", + }, + } + for desc, tc := range cases { + t.Run(desc, func(t *testing.T) { + d := InitMockDebugger() + p := dummyPersister(d) + fs := afero.NewMemMapFs() + p.SetFS(fs) + + resp := p.Persist(tc.input...) + + assert.Len(t, resp.File, 0) + assert.Equal(t, tc.output, resp.GetError()) + }) + } +} diff --git a/vendor/golang.org/x/net/bpf/constants.go b/vendor/golang.org/x/net/bpf/constants.go index b89ca3523..12f3ee835 100644 --- a/vendor/golang.org/x/net/bpf/constants.go +++ b/vendor/golang.org/x/net/bpf/constants.go @@ -38,6 +38,7 @@ const ( type JumpTest uint16 // Supported operators for conditional jumps. +// K can be RegX for JumpIfX const ( // K == A JumpEqual JumpTest = iota @@ -134,12 +135,9 @@ const ( opMaskLoadDest = 0x01 opMaskLoadWidth = 0x18 opMaskLoadMode = 0xe0 - // opClsALU - opMaskOperandSrc = 0x08 - opMaskOperator = 0xf0 - // opClsJump - opMaskJumpConst = 0x0f - opMaskJumpCond = 0xf0 + // opClsALU & opClsJump + opMaskOperand = 0x08 + opMaskOperator = 0xf0 ) const ( @@ -192,15 +190,21 @@ const ( opLoadWidth1 ) -// Operator defined by ALUOp* +// Operand for ALU and Jump instructions +type opOperand uint16 +// Supported operand sources. const ( - opALUSrcConstant uint16 = iota << 3 - opALUSrcX + opOperandConstant opOperand = iota << 3 + opOperandX ) +// An jumpOp is a conditional jump condition. +type jumpOp uint16 + +// Supported jump conditions. const ( - opJumpAlways = iota << 4 + opJumpAlways jumpOp = iota << 4 opJumpEqual opJumpGT opJumpGE diff --git a/vendor/golang.org/x/net/bpf/instructions.go b/vendor/golang.org/x/net/bpf/instructions.go index f9dc0e8ee..3cffcaa01 100644 --- a/vendor/golang.org/x/net/bpf/instructions.go +++ b/vendor/golang.org/x/net/bpf/instructions.go @@ -89,10 +89,14 @@ func (ri RawInstruction) Disassemble() Instruction { case opClsALU: switch op := ALUOp(ri.Op & opMaskOperator); op { case ALUOpAdd, ALUOpSub, ALUOpMul, ALUOpDiv, ALUOpOr, ALUOpAnd, ALUOpShiftLeft, ALUOpShiftRight, ALUOpMod, ALUOpXor: - if ri.Op&opMaskOperandSrc != 0 { + switch operand := opOperand(ri.Op & opMaskOperand); operand { + case opOperandX: return ALUOpX{Op: op} + case opOperandConstant: + return ALUOpConstant{Op: op, Val: ri.K} + default: + return ri } - return ALUOpConstant{Op: op, Val: ri.K} case aluOpNeg: return NegateA{} default: @@ -100,63 +104,18 @@ func (ri RawInstruction) Disassemble() Instruction { } case opClsJump: - if ri.Op&opMaskJumpConst != opClsJump { - return ri - } - switch ri.Op & opMaskJumpCond { + switch op := jumpOp(ri.Op & opMaskOperator); op { case opJumpAlways: return Jump{Skip: ri.K} - case opJumpEqual: - if ri.Jt == 0 { - return JumpIf{ - Cond: JumpNotEqual, - Val: ri.K, - SkipTrue: ri.Jf, - SkipFalse: 0, - } - } - return JumpIf{ - Cond: JumpEqual, - Val: ri.K, - SkipTrue: ri.Jt, - SkipFalse: ri.Jf, - } - case opJumpGT: - if ri.Jt == 0 { - return JumpIf{ - Cond: JumpLessOrEqual, - Val: ri.K, - SkipTrue: ri.Jf, - SkipFalse: 0, - } - } - return JumpIf{ - Cond: JumpGreaterThan, - Val: ri.K, - SkipTrue: ri.Jt, - SkipFalse: ri.Jf, - } - case opJumpGE: - if ri.Jt == 0 { - return JumpIf{ - Cond: JumpLessThan, - Val: ri.K, - SkipTrue: ri.Jf, - SkipFalse: 0, - } - } - return JumpIf{ - Cond: JumpGreaterOrEqual, - Val: ri.K, - SkipTrue: ri.Jt, - SkipFalse: ri.Jf, - } - case opJumpSet: - return JumpIf{ - Cond: JumpBitsSet, - Val: ri.K, - SkipTrue: ri.Jt, - SkipFalse: ri.Jf, + case opJumpEqual, opJumpGT, opJumpGE, opJumpSet: + cond, skipTrue, skipFalse := jumpOpToTest(op, ri.Jt, ri.Jf) + switch operand := opOperand(ri.Op & opMaskOperand); operand { + case opOperandX: + return JumpIfX{Cond: cond, SkipTrue: skipTrue, SkipFalse: skipFalse} + case opOperandConstant: + return JumpIf{Cond: cond, Val: ri.K, SkipTrue: skipTrue, SkipFalse: skipFalse} + default: + return ri } default: return ri @@ -187,6 +146,41 @@ func (ri RawInstruction) Disassemble() Instruction { } } +func jumpOpToTest(op jumpOp, skipTrue uint8, skipFalse uint8) (JumpTest, uint8, uint8) { + var test JumpTest + + // Decode "fake" jump conditions that don't appear in machine code + // Ensures the Assemble -> Disassemble stage recreates the same instructions + // See https://github.com/golang/go/issues/18470 + if skipTrue == 0 { + switch op { + case opJumpEqual: + test = JumpNotEqual + case opJumpGT: + test = JumpLessOrEqual + case opJumpGE: + test = JumpLessThan + case opJumpSet: + test = JumpBitsNotSet + } + + return test, skipFalse, 0 + } + + switch op { + case opJumpEqual: + test = JumpEqual + case opJumpGT: + test = JumpGreaterThan + case opJumpGE: + test = JumpGreaterOrEqual + case opJumpSet: + test = JumpBitsSet + } + + return test, skipTrue, skipFalse +} + // LoadConstant loads Val into register Dst. type LoadConstant struct { Dst Register @@ -413,7 +407,7 @@ type ALUOpConstant struct { // Assemble implements the Instruction Assemble method. func (a ALUOpConstant) Assemble() (RawInstruction, error) { return RawInstruction{ - Op: opClsALU | opALUSrcConstant | uint16(a.Op), + Op: opClsALU | uint16(opOperandConstant) | uint16(a.Op), K: a.Val, }, nil } @@ -454,7 +448,7 @@ type ALUOpX struct { // Assemble implements the Instruction Assemble method. func (a ALUOpX) Assemble() (RawInstruction, error) { return RawInstruction{ - Op: opClsALU | opALUSrcX | uint16(a.Op), + Op: opClsALU | uint16(opOperandX) | uint16(a.Op), }, nil } @@ -509,7 +503,7 @@ type Jump struct { // Assemble implements the Instruction Assemble method. func (a Jump) Assemble() (RawInstruction, error) { return RawInstruction{ - Op: opClsJump | opJumpAlways, + Op: opClsJump | uint16(opJumpAlways), K: a.Skip, }, nil } @@ -530,11 +524,39 @@ type JumpIf struct { // Assemble implements the Instruction Assemble method. func (a JumpIf) Assemble() (RawInstruction, error) { + return jumpToRaw(a.Cond, opOperandConstant, a.Val, a.SkipTrue, a.SkipFalse) +} + +// String returns the instruction in assembler notation. +func (a JumpIf) String() string { + return jumpToString(a.Cond, fmt.Sprintf("#%d", a.Val), a.SkipTrue, a.SkipFalse) +} + +// JumpIfX skips the following Skip instructions in the program if A +// X is true. +type JumpIfX struct { + Cond JumpTest + SkipTrue uint8 + SkipFalse uint8 +} + +// Assemble implements the Instruction Assemble method. +func (a JumpIfX) Assemble() (RawInstruction, error) { + return jumpToRaw(a.Cond, opOperandX, 0, a.SkipTrue, a.SkipFalse) +} + +// String returns the instruction in assembler notation. +func (a JumpIfX) String() string { + return jumpToString(a.Cond, "x", a.SkipTrue, a.SkipFalse) +} + +// jumpToRaw assembles a jump instruction into a RawInstruction +func jumpToRaw(test JumpTest, operand opOperand, k uint32, skipTrue, skipFalse uint8) (RawInstruction, error) { var ( - cond uint16 + cond jumpOp flip bool ) - switch a.Cond { + switch test { case JumpEqual: cond = opJumpEqual case JumpNotEqual: @@ -552,63 +574,63 @@ func (a JumpIf) Assemble() (RawInstruction, error) { case JumpBitsNotSet: cond, flip = opJumpSet, true default: - return RawInstruction{}, fmt.Errorf("unknown JumpTest %v", a.Cond) + return RawInstruction{}, fmt.Errorf("unknown JumpTest %v", test) } - jt, jf := a.SkipTrue, a.SkipFalse + jt, jf := skipTrue, skipFalse if flip { jt, jf = jf, jt } return RawInstruction{ - Op: opClsJump | cond, + Op: opClsJump | uint16(cond) | uint16(operand), Jt: jt, Jf: jf, - K: a.Val, + K: k, }, nil } -// String returns the instruction in assembler notation. -func (a JumpIf) String() string { - switch a.Cond { +// jumpToString converts a jump instruction to assembler notation +func jumpToString(cond JumpTest, operand string, skipTrue, skipFalse uint8) string { + switch cond { // K == A case JumpEqual: - return conditionalJump(a, "jeq", "jneq") + return conditionalJump(operand, skipTrue, skipFalse, "jeq", "jneq") // K != A case JumpNotEqual: - return fmt.Sprintf("jneq #%d,%d", a.Val, a.SkipTrue) + return fmt.Sprintf("jneq %s,%d", operand, skipTrue) // K > A case JumpGreaterThan: - return conditionalJump(a, "jgt", "jle") + return conditionalJump(operand, skipTrue, skipFalse, "jgt", "jle") // K < A case JumpLessThan: - return fmt.Sprintf("jlt #%d,%d", a.Val, a.SkipTrue) + return fmt.Sprintf("jlt %s,%d", operand, skipTrue) // K >= A case JumpGreaterOrEqual: - return conditionalJump(a, "jge", "jlt") + return conditionalJump(operand, skipTrue, skipFalse, "jge", "jlt") // K <= A case JumpLessOrEqual: - return fmt.Sprintf("jle #%d,%d", a.Val, a.SkipTrue) + return fmt.Sprintf("jle %s,%d", operand, skipTrue) // K & A != 0 case JumpBitsSet: - if a.SkipFalse > 0 { - return fmt.Sprintf("jset #%d,%d,%d", a.Val, a.SkipTrue, a.SkipFalse) + if skipFalse > 0 { + return fmt.Sprintf("jset %s,%d,%d", operand, skipTrue, skipFalse) } - return fmt.Sprintf("jset #%d,%d", a.Val, a.SkipTrue) + return fmt.Sprintf("jset %s,%d", operand, skipTrue) // K & A == 0, there is no assembler instruction for JumpBitNotSet, use JumpBitSet and invert skips case JumpBitsNotSet: - return JumpIf{Cond: JumpBitsSet, SkipTrue: a.SkipFalse, SkipFalse: a.SkipTrue, Val: a.Val}.String() + return jumpToString(JumpBitsSet, operand, skipFalse, skipTrue) default: - return fmt.Sprintf("unknown instruction: %#v", a) + return fmt.Sprintf("unknown JumpTest %#v", cond) } } -func conditionalJump(inst JumpIf, positiveJump, negativeJump string) string { - if inst.SkipTrue > 0 { - if inst.SkipFalse > 0 { - return fmt.Sprintf("%s #%d,%d,%d", positiveJump, inst.Val, inst.SkipTrue, inst.SkipFalse) +func conditionalJump(operand string, skipTrue, skipFalse uint8, positiveJump, negativeJump string) string { + if skipTrue > 0 { + if skipFalse > 0 { + return fmt.Sprintf("%s %s,%d,%d", positiveJump, operand, skipTrue, skipFalse) } - return fmt.Sprintf("%s #%d,%d", positiveJump, inst.Val, inst.SkipTrue) + return fmt.Sprintf("%s %s,%d", positiveJump, operand, skipTrue) } - return fmt.Sprintf("%s #%d,%d", negativeJump, inst.Val, inst.SkipFalse) + return fmt.Sprintf("%s %s,%d", negativeJump, operand, skipFalse) } // RetA exits the BPF program, returning the value of register A. diff --git a/vendor/golang.org/x/net/bpf/instructions_test.go b/vendor/golang.org/x/net/bpf/instructions_test.go index dde474aba..69b25c541 100644 --- a/vendor/golang.org/x/net/bpf/instructions_test.go +++ b/vendor/golang.org/x/net/bpf/instructions_test.go @@ -64,14 +64,22 @@ var allInstructions = []Instruction{ NegateA{}, - Jump{Skip: 10}, - JumpIf{Cond: JumpEqual, Val: 42, SkipTrue: 8, SkipFalse: 9}, - JumpIf{Cond: JumpNotEqual, Val: 42, SkipTrue: 8}, - JumpIf{Cond: JumpLessThan, Val: 42, SkipTrue: 7}, - JumpIf{Cond: JumpLessOrEqual, Val: 42, SkipTrue: 6}, - JumpIf{Cond: JumpGreaterThan, Val: 42, SkipTrue: 4, SkipFalse: 5}, - JumpIf{Cond: JumpGreaterOrEqual, Val: 42, SkipTrue: 3, SkipFalse: 4}, - JumpIf{Cond: JumpBitsSet, Val: 42, SkipTrue: 2, SkipFalse: 3}, + Jump{Skip: 17}, + JumpIf{Cond: JumpEqual, Val: 42, SkipTrue: 15, SkipFalse: 16}, + JumpIf{Cond: JumpNotEqual, Val: 42, SkipTrue: 15}, + JumpIf{Cond: JumpLessThan, Val: 42, SkipTrue: 14}, + JumpIf{Cond: JumpLessOrEqual, Val: 42, SkipTrue: 13}, + JumpIf{Cond: JumpGreaterThan, Val: 42, SkipTrue: 11, SkipFalse: 12}, + JumpIf{Cond: JumpGreaterOrEqual, Val: 42, SkipTrue: 10, SkipFalse: 11}, + JumpIf{Cond: JumpBitsSet, Val: 42, SkipTrue: 9, SkipFalse: 10}, + + JumpIfX{Cond: JumpEqual, SkipTrue: 8, SkipFalse: 9}, + JumpIfX{Cond: JumpNotEqual, SkipTrue: 8}, + JumpIfX{Cond: JumpLessThan, SkipTrue: 7}, + JumpIfX{Cond: JumpLessOrEqual, SkipTrue: 6}, + JumpIfX{Cond: JumpGreaterThan, SkipTrue: 4, SkipFalse: 5}, + JumpIfX{Cond: JumpGreaterOrEqual, SkipTrue: 3, SkipFalse: 4}, + JumpIfX{Cond: JumpBitsSet, SkipTrue: 2, SkipFalse: 3}, TAX{}, TXA{}, @@ -487,7 +495,67 @@ func TestString(t *testing.T) { }, { instruction: JumpIf{Cond: 0xffff, Val: 42, SkipTrue: 1, SkipFalse: 2}, - assembler: "unknown instruction: bpf.JumpIf{Cond:0xffff, Val:0x2a, SkipTrue:0x1, SkipFalse:0x2}", + assembler: "unknown JumpTest 0xffff", + }, + { + instruction: JumpIfX{Cond: JumpEqual, SkipTrue: 8, SkipFalse: 9}, + assembler: "jeq x,8,9", + }, + { + instruction: JumpIfX{Cond: JumpEqual, SkipTrue: 8}, + assembler: "jeq x,8", + }, + { + instruction: JumpIfX{Cond: JumpEqual, SkipFalse: 8}, + assembler: "jneq x,8", + }, + { + instruction: JumpIfX{Cond: JumpNotEqual, SkipTrue: 8}, + assembler: "jneq x,8", + }, + { + instruction: JumpIfX{Cond: JumpLessThan, SkipTrue: 7}, + assembler: "jlt x,7", + }, + { + instruction: JumpIfX{Cond: JumpLessOrEqual, SkipTrue: 6}, + assembler: "jle x,6", + }, + { + instruction: JumpIfX{Cond: JumpGreaterThan, SkipTrue: 4, SkipFalse: 5}, + assembler: "jgt x,4,5", + }, + { + instruction: JumpIfX{Cond: JumpGreaterThan, SkipTrue: 4}, + assembler: "jgt x,4", + }, + { + instruction: JumpIfX{Cond: JumpGreaterOrEqual, SkipTrue: 3, SkipFalse: 4}, + assembler: "jge x,3,4", + }, + { + instruction: JumpIfX{Cond: JumpGreaterOrEqual, SkipTrue: 3}, + assembler: "jge x,3", + }, + { + instruction: JumpIfX{Cond: JumpBitsSet, SkipTrue: 2, SkipFalse: 3}, + assembler: "jset x,2,3", + }, + { + instruction: JumpIfX{Cond: JumpBitsSet, SkipTrue: 2}, + assembler: "jset x,2", + }, + { + instruction: JumpIfX{Cond: JumpBitsNotSet, SkipTrue: 2, SkipFalse: 3}, + assembler: "jset x,3,2", + }, + { + instruction: JumpIfX{Cond: JumpBitsNotSet, SkipTrue: 2}, + assembler: "jset x,0,2", + }, + { + instruction: JumpIfX{Cond: 0xffff, SkipTrue: 1, SkipFalse: 2}, + assembler: "unknown JumpTest 0xffff", }, { instruction: TAX{}, diff --git a/vendor/golang.org/x/net/bpf/testdata/all_instructions.bpf b/vendor/golang.org/x/net/bpf/testdata/all_instructions.bpf index f87144064..929eb25ac 100644 --- a/vendor/golang.org/x/net/bpf/testdata/all_instructions.bpf +++ b/vendor/golang.org/x/net/bpf/testdata/all_instructions.bpf @@ -1 +1 @@ -50,0 0 0 42,1 0 0 42,96 0 0 3,97 0 0 3,48 0 0 42,40 0 0 42,32 0 0 42,80 0 0 42,72 0 0 42,64 0 0 42,177 0 0 42,128 0 0 0,32 0 0 4294963200,32 0 0 4294963204,32 0 0 4294963256,2 0 0 3,3 0 0 3,4 0 0 42,20 0 0 42,36 0 0 42,52 0 0 42,68 0 0 42,84 0 0 42,100 0 0 42,116 0 0 42,148 0 0 42,164 0 0 42,12 0 0 0,28 0 0 0,44 0 0 0,60 0 0 0,76 0 0 0,92 0 0 0,108 0 0 0,124 0 0 0,156 0 0 0,172 0 0 0,132 0 0 0,5 0 0 10,21 8 9 42,21 0 8 42,53 0 7 42,37 0 6 42,37 4 5 42,53 3 4 42,69 2 3 42,7 0 0 0,135 0 0 0,22 0 0 0,6 0 0 0, +57,0 0 0 42,1 0 0 42,96 0 0 3,97 0 0 3,48 0 0 42,40 0 0 42,32 0 0 42,80 0 0 42,72 0 0 42,64 0 0 42,177 0 0 42,128 0 0 0,32 0 0 4294963200,32 0 0 4294963204,32 0 0 4294963256,2 0 0 3,3 0 0 3,4 0 0 42,20 0 0 42,36 0 0 42,52 0 0 42,68 0 0 42,84 0 0 42,100 0 0 42,116 0 0 42,148 0 0 42,164 0 0 42,12 0 0 0,28 0 0 0,44 0 0 0,60 0 0 0,76 0 0 0,92 0 0 0,108 0 0 0,124 0 0 0,156 0 0 0,172 0 0 0,132 0 0 0,5 0 0 17,21 15 16 42,21 0 15 42,53 0 14 42,37 0 13 42,37 11 12 42,53 10 11 42,69 9 10 42,29 8 9 0,29 0 8 0,61 0 7 0,45 0 6 0,45 4 5 0,61 3 4 0,77 2 3 0,7 0 0 0,135 0 0 0,22 0 0 0,6 0 0 42, diff --git a/vendor/golang.org/x/net/bpf/testdata/all_instructions.txt b/vendor/golang.org/x/net/bpf/testdata/all_instructions.txt index 304550155..8e4d7587c 100644 --- a/vendor/golang.org/x/net/bpf/testdata/all_instructions.txt +++ b/vendor/golang.org/x/net/bpf/testdata/all_instructions.txt @@ -1,6 +1,6 @@ # This filter is compiled to all_instructions.bpf by the `bpf_asm` # tool, which can be found in the linux kernel source tree under -# tools/net. +# tools/bpf. # Load immediate ld #42 @@ -60,7 +60,7 @@ xor x # !A neg -# Jumps +# Jump A constant ja end jeq #42,prev,end jne #42,end @@ -70,6 +70,15 @@ jgt #42,prev,end jge #42,prev,end jset #42,prev,end +# Jump A X +jeq x,prev,end +jne x,end +jlt x,end +jle x,end +jgt x,prev,end +jge x,prev,end +jset x,prev,end + # Register transfers tax txa diff --git a/vendor/golang.org/x/net/bpf/vm.go b/vendor/golang.org/x/net/bpf/vm.go index 4c656f1e1..73f57f1f7 100644 --- a/vendor/golang.org/x/net/bpf/vm.go +++ b/vendor/golang.org/x/net/bpf/vm.go @@ -35,6 +35,13 @@ func NewVM(filter []Instruction) (*VM, error) { if check <= int(ins.SkipFalse) { return nil, fmt.Errorf("cannot jump %d instructions in false case; jumping past program bounds", ins.SkipFalse) } + case JumpIfX: + if check <= int(ins.SkipTrue) { + return nil, fmt.Errorf("cannot jump %d instructions in true case; jumping past program bounds", ins.SkipTrue) + } + if check <= int(ins.SkipFalse) { + return nil, fmt.Errorf("cannot jump %d instructions in false case; jumping past program bounds", ins.SkipFalse) + } // Check for division or modulus by zero case ALUOpConstant: if ins.Val != 0 { @@ -109,6 +116,9 @@ func (v *VM) Run(in []byte) (int, error) { case JumpIf: jump := jumpIf(ins, regA) i += jump + case JumpIfX: + jump := jumpIfX(ins, regA, regX) + i += jump case LoadAbsolute: regA, ok = loadAbsolute(ins, in) case LoadConstant: diff --git a/vendor/golang.org/x/net/bpf/vm_instructions.go b/vendor/golang.org/x/net/bpf/vm_instructions.go index 516f9462b..f0d2e55bd 100644 --- a/vendor/golang.org/x/net/bpf/vm_instructions.go +++ b/vendor/golang.org/x/net/bpf/vm_instructions.go @@ -55,34 +55,41 @@ func aluOpCommon(op ALUOp, regA uint32, value uint32) uint32 { } } -func jumpIf(ins JumpIf, value uint32) int { +func jumpIf(ins JumpIf, regA uint32) int { + return jumpIfCommon(ins.Cond, ins.SkipTrue, ins.SkipFalse, regA, ins.Val) +} + +func jumpIfX(ins JumpIfX, regA uint32, regX uint32) int { + return jumpIfCommon(ins.Cond, ins.SkipTrue, ins.SkipFalse, regA, regX) +} + +func jumpIfCommon(cond JumpTest, skipTrue, skipFalse uint8, regA uint32, value uint32) int { var ok bool - inV := uint32(ins.Val) - switch ins.Cond { + switch cond { case JumpEqual: - ok = value == inV + ok = regA == value case JumpNotEqual: - ok = value != inV + ok = regA != value case JumpGreaterThan: - ok = value > inV + ok = regA > value case JumpLessThan: - ok = value < inV + ok = regA < value case JumpGreaterOrEqual: - ok = value >= inV + ok = regA >= value case JumpLessOrEqual: - ok = value <= inV + ok = regA <= value case JumpBitsSet: - ok = (value & inV) != 0 + ok = (regA & value) != 0 case JumpBitsNotSet: - ok = (value & inV) == 0 + ok = (regA & value) == 0 } if ok { - return int(ins.SkipTrue) + return int(skipTrue) } - return int(ins.SkipFalse) + return int(skipFalse) } func loadAbsolute(ins LoadAbsolute, in []byte) (uint32, bool) { diff --git a/vendor/golang.org/x/net/bpf/vm_jump_test.go b/vendor/golang.org/x/net/bpf/vm_jump_test.go index e0a3a988b..77a2d4703 100644 --- a/vendor/golang.org/x/net/bpf/vm_jump_test.go +++ b/vendor/golang.org/x/net/bpf/vm_jump_test.go @@ -83,6 +83,32 @@ func TestVMJumpIfFalseOutOfProgram(t *testing.T) { } } +func TestVMJumpIfXTrueOutOfProgram(t *testing.T) { + _, _, err := testVM(t, []bpf.Instruction{ + bpf.JumpIfX{ + Cond: bpf.JumpEqual, + SkipTrue: 2, + }, + bpf.RetA{}, + }) + if errStr(err) != "cannot jump 2 instructions in true case; jumping past program bounds" { + t.Fatalf("unexpected error: %v", err) + } +} + +func TestVMJumpIfXFalseOutOfProgram(t *testing.T) { + _, _, err := testVM(t, []bpf.Instruction{ + bpf.JumpIfX{ + Cond: bpf.JumpEqual, + SkipFalse: 3, + }, + bpf.RetA{}, + }) + if errStr(err) != "cannot jump 3 instructions in false case; jumping past program bounds" { + t.Fatalf("unexpected error: %v", err) + } +} + func TestVMJumpIfEqual(t *testing.T) { vm, done, err := testVM(t, []bpf.Instruction{ bpf.LoadAbsolute{ @@ -378,3 +404,323 @@ func TestVMJumpIfBitsNotSet(t *testing.T) { want, got) } } + +func TestVMJumpIfXEqual(t *testing.T) { + vm, done, err := testVM(t, []bpf.Instruction{ + bpf.LoadAbsolute{ + Off: 8, + Size: 1, + }, + bpf.LoadConstant{ + Dst: bpf.RegX, + Val: 1, + }, + bpf.JumpIfX{ + Cond: bpf.JumpEqual, + SkipTrue: 1, + }, + bpf.RetConstant{ + Val: 0, + }, + bpf.RetConstant{ + Val: 9, + }, + }) + if err != nil { + t.Fatalf("failed to load BPF program: %v", err) + } + defer done() + + out, err := vm.Run([]byte{ + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 1, + }) + if err != nil { + t.Fatalf("unexpected error while running program: %v", err) + } + if want, got := 1, out; want != got { + t.Fatalf("unexpected number of output bytes:\n- want: %d\n- got: %d", + want, got) + } +} + +func TestVMJumpIfXNotEqual(t *testing.T) { + vm, done, err := testVM(t, []bpf.Instruction{ + bpf.LoadAbsolute{ + Off: 8, + Size: 1, + }, + bpf.LoadConstant{ + Dst: bpf.RegX, + Val: 1, + }, + bpf.JumpIfX{ + Cond: bpf.JumpNotEqual, + SkipFalse: 1, + }, + bpf.RetConstant{ + Val: 0, + }, + bpf.RetConstant{ + Val: 9, + }, + }) + if err != nil { + t.Fatalf("failed to load BPF program: %v", err) + } + defer done() + + out, err := vm.Run([]byte{ + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 1, + }) + if err != nil { + t.Fatalf("unexpected error while running program: %v", err) + } + if want, got := 1, out; want != got { + t.Fatalf("unexpected number of output bytes:\n- want: %d\n- got: %d", + want, got) + } +} + +func TestVMJumpIfXGreaterThan(t *testing.T) { + vm, done, err := testVM(t, []bpf.Instruction{ + bpf.LoadAbsolute{ + Off: 8, + Size: 4, + }, + bpf.LoadConstant{ + Dst: bpf.RegX, + Val: 0x00010202, + }, + bpf.JumpIfX{ + Cond: bpf.JumpGreaterThan, + SkipTrue: 1, + }, + bpf.RetConstant{ + Val: 0, + }, + bpf.RetConstant{ + Val: 12, + }, + }) + if err != nil { + t.Fatalf("failed to load BPF program: %v", err) + } + defer done() + + out, err := vm.Run([]byte{ + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0, 1, 2, 3, + }) + if err != nil { + t.Fatalf("unexpected error while running program: %v", err) + } + if want, got := 4, out; want != got { + t.Fatalf("unexpected number of output bytes:\n- want: %d\n- got: %d", + want, got) + } +} + +func TestVMJumpIfXLessThan(t *testing.T) { + vm, done, err := testVM(t, []bpf.Instruction{ + bpf.LoadAbsolute{ + Off: 8, + Size: 4, + }, + bpf.LoadConstant{ + Dst: bpf.RegX, + Val: 0xff010203, + }, + bpf.JumpIfX{ + Cond: bpf.JumpLessThan, + SkipTrue: 1, + }, + bpf.RetConstant{ + Val: 0, + }, + bpf.RetConstant{ + Val: 12, + }, + }) + if err != nil { + t.Fatalf("failed to load BPF program: %v", err) + } + defer done() + + out, err := vm.Run([]byte{ + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0, 1, 2, 3, + }) + if err != nil { + t.Fatalf("unexpected error while running program: %v", err) + } + if want, got := 4, out; want != got { + t.Fatalf("unexpected number of output bytes:\n- want: %d\n- got: %d", + want, got) + } +} + +func TestVMJumpIfXGreaterOrEqual(t *testing.T) { + vm, done, err := testVM(t, []bpf.Instruction{ + bpf.LoadAbsolute{ + Off: 8, + Size: 4, + }, + bpf.LoadConstant{ + Dst: bpf.RegX, + Val: 0x00010203, + }, + bpf.JumpIfX{ + Cond: bpf.JumpGreaterOrEqual, + SkipTrue: 1, + }, + bpf.RetConstant{ + Val: 0, + }, + bpf.RetConstant{ + Val: 12, + }, + }) + if err != nil { + t.Fatalf("failed to load BPF program: %v", err) + } + defer done() + + out, err := vm.Run([]byte{ + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0, 1, 2, 3, + }) + if err != nil { + t.Fatalf("unexpected error while running program: %v", err) + } + if want, got := 4, out; want != got { + t.Fatalf("unexpected number of output bytes:\n- want: %d\n- got: %d", + want, got) + } +} + +func TestVMJumpIfXLessOrEqual(t *testing.T) { + vm, done, err := testVM(t, []bpf.Instruction{ + bpf.LoadAbsolute{ + Off: 8, + Size: 4, + }, + bpf.LoadConstant{ + Dst: bpf.RegX, + Val: 0xff010203, + }, + bpf.JumpIfX{ + Cond: bpf.JumpLessOrEqual, + SkipTrue: 1, + }, + bpf.RetConstant{ + Val: 0, + }, + bpf.RetConstant{ + Val: 12, + }, + }) + if err != nil { + t.Fatalf("failed to load BPF program: %v", err) + } + defer done() + + out, err := vm.Run([]byte{ + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0, 1, 2, 3, + }) + if err != nil { + t.Fatalf("unexpected error while running program: %v", err) + } + if want, got := 4, out; want != got { + t.Fatalf("unexpected number of output bytes:\n- want: %d\n- got: %d", + want, got) + } +} + +func TestVMJumpIfXBitsSet(t *testing.T) { + vm, done, err := testVM(t, []bpf.Instruction{ + bpf.LoadAbsolute{ + Off: 8, + Size: 2, + }, + bpf.LoadConstant{ + Dst: bpf.RegX, + Val: 0x1122, + }, + bpf.JumpIfX{ + Cond: bpf.JumpBitsSet, + SkipTrue: 1, + }, + bpf.RetConstant{ + Val: 0, + }, + bpf.RetConstant{ + Val: 10, + }, + }) + if err != nil { + t.Fatalf("failed to load BPF program: %v", err) + } + defer done() + + out, err := vm.Run([]byte{ + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0x01, 0x02, + }) + if err != nil { + t.Fatalf("unexpected error while running program: %v", err) + } + if want, got := 2, out; want != got { + t.Fatalf("unexpected number of output bytes:\n- want: %d\n- got: %d", + want, got) + } +} + +func TestVMJumpIfXBitsNotSet(t *testing.T) { + vm, done, err := testVM(t, []bpf.Instruction{ + bpf.LoadAbsolute{ + Off: 8, + Size: 2, + }, + bpf.LoadConstant{ + Dst: bpf.RegX, + Val: 0x1221, + }, + bpf.JumpIfX{ + Cond: bpf.JumpBitsNotSet, + SkipTrue: 1, + }, + bpf.RetConstant{ + Val: 0, + }, + bpf.RetConstant{ + Val: 10, + }, + }) + if err != nil { + t.Fatalf("failed to load BPF program: %v", err) + } + defer done() + + out, err := vm.Run([]byte{ + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0x01, 0x02, + }) + if err != nil { + t.Fatalf("unexpected error while running program: %v", err) + } + if want, got := 2, out; want != got { + t.Fatalf("unexpected number of output bytes:\n- want: %d\n- got: %d", + want, got) + } +} diff --git a/vendor/golang.org/x/net/html/const.go b/vendor/golang.org/x/net/html/const.go index 5eb7c5a8f..a3a918f0b 100644 --- a/vendor/golang.org/x/net/html/const.go +++ b/vendor/golang.org/x/net/html/const.go @@ -97,8 +97,16 @@ func isSpecialElement(element *Node) bool { switch element.Namespace { case "", "html": return isSpecialElementMap[element.Data] + case "math": + switch element.Data { + case "mi", "mo", "mn", "ms", "mtext", "annotation-xml": + return true + } case "svg": - return element.Data == "foreignObject" + switch element.Data { + case "foreignObject", "desc", "title": + return true + } } return false } diff --git a/vendor/golang.org/x/net/html/parse.go b/vendor/golang.org/x/net/html/parse.go index 091fb0d13..64a579372 100644 --- a/vendor/golang.org/x/net/html/parse.go +++ b/vendor/golang.org/x/net/html/parse.go @@ -470,6 +470,10 @@ func (p *parser) resetInsertionMode() { case a.Table: p.im = inTableIM case a.Template: + // TODO: remove this divergence from the HTML5 spec. + if n.Namespace != "" { + continue + } p.im = p.templateStack.top() case a.Head: // TODO: remove this divergence from the HTML5 spec. @@ -984,6 +988,14 @@ func inBodyIM(p *parser) bool { p.acknowledgeSelfClosingTag() p.popUntil(buttonScope, a.P) p.parseImpliedToken(StartTagToken, a.Form, a.Form.String()) + if p.form == nil { + // NOTE: The 'isindex' element has been removed, + // and the 'template' element has not been designed to be + // collaborative with the index element. + // + // Ignore the token. + return true + } if action != "" { p.form.Attr = []Attribute{{Key: "action", Val: action}} } @@ -1252,12 +1264,6 @@ func (p *parser) inBodyEndTagFormatting(tagAtom a.Atom) { switch commonAncestor.DataAtom { case a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr: p.fosterParent(lastNode) - case a.Template: - // TODO: remove namespace checking - if commonAncestor.Namespace == "html" { - commonAncestor = commonAncestor.LastChild - } - fallthrough default: commonAncestor.AppendChild(lastNode) } diff --git a/vendor/golang.org/x/net/html/testdata/go/template.dat b/vendor/golang.org/x/net/html/testdata/go/template.dat index a0a525bc0..98481b9e6 100644 --- a/vendor/golang.org/x/net/html/testdata/go/template.dat +++ b/vendor/golang.org/x/net/html/testdata/go/template.dat @@ -11,3 +11,27 @@ |
| |