From 954507869406851cb0be7cb63ba90251bfdfa4d8 Mon Sep 17 00:00:00 2001 From: Adrian Hesketh Date: Mon, 7 Jun 2021 22:01:11 +0100 Subject: [PATCH] increase maximum size of attribute name from 15 characters to 128 - fixes #15 --- elementparser.go | 2 +- elementparser_test.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/elementparser.go b/elementparser.go index e620b2b91..d918e7f48 100644 --- a/elementparser.go +++ b/elementparser.go @@ -62,7 +62,7 @@ var attributeNameFirst = "abcdefghijklmnopqrstuvwxyz" var attributeNameSubsequent = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-" var attributeNameParser = parse.Then(parse.WithStringConcatCombiner, parse.RuneIn(elementNameFirst), - parse.Many(parse.WithStringConcatCombiner, 0, 15, parse.RuneIn(elementNameSubsequent)), + parse.Many(parse.WithStringConcatCombiner, 0, 128, parse.RuneIn(elementNameSubsequent)), ) // Constant attribute. diff --git a/elementparser_test.go b/elementparser_test.go index 9c06a3989..252dcf96e 100644 --- a/elementparser_test.go +++ b/elementparser_test.go @@ -60,6 +60,24 @@ func TestAttributeParser(t *testing.T) { Value: "test", }, }, + { + name: "attribute name with hyphens", + input: ` data-turbo-permanent="value"`, + parser: newConstantAttributeParser().Parse, + expected: ConstantAttribute{ + Name: "data-turbo-permanent", + Value: "value", + }, + }, + { + name: "empty attribute", + input: ` data=""`, + parser: newConstantAttributeParser().Parse, + expected: ConstantAttribute{ + Name: "data", + Value: "", + }, + }, { name: "attribute containing escaped text", input: ` href="<">"`,