Skip to content

Commit df8c832

Browse files
andyjackoalders
authored andcommitted
ongoing work
1 parent 8be4c36 commit df8c832

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Makefile
99
MYMETA.*
1010
.build/
1111
HTML-Parser-*/
12-
12+
local/

hparser.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ static const char * const argname[] = {
8888
/* https://meiert.com/en/blog/boolean-attributes-of-html/ */
8989
const static struct boolean_attribute {
9090
int len;
91-
char* str;
91+
const char* str;
9292
}
9393
boolean_attributes[] = {
9494
{15, "allowfullscreen"},
9595
{19, "allowpaymentrequest"},
9696
{5, "async"},
9797
{9, "autofocus"},
9898
{8, "autoplay"},
99-
{6, "checked"},
99+
{7, "checked"},
100100
{8, "controls"},
101101
{7, "default"},
102102
{8, "disabled"},
@@ -500,10 +500,11 @@ report_event(PSTATE* p_state,
500500
}
501501
else { /* boolean */
502502
int i;
503+
int found = 0;
503504
for ( i = 0; boolean_attributes[i].len; i++ ) {
504505
if( attrlen == boolean_attributes[i].len ) {
505-
char *attrname_s = tokens[i].beg;
506-
char *t = boolean_attributes[i].str;
506+
char *attrname_s = SvPVbyte_nolen(attrname);
507+
const char *t = boolean_attributes[i].str;
507508
int len = attrlen;
508509
while(len) {
509510
if(toLOWER(*attrname_s) != *t)
@@ -517,14 +518,14 @@ report_event(PSTATE* p_state,
517518
else
518519
attrval = newSVsv(attrname);
519520
}
520-
goto BOOLEAN_ATTR_MATCH_DONE;
521-
}
521+
found = 1;
522+
}
522523
}
523524
}
524525
/* no matches were found, so set attr to undef */
525-
attrval = newSV(0);
526-
BOOLEAN_ATTR_MATCH_DONE:
527-
;
526+
if (!found)
527+
attrval = newSV(0);
528+
528529
}
529530

530531
if (!CASE_SENSITIVE(p_state))

t/cases.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ my @tests = (
9494
'<!-- comment <!-- not comment --> comment -->' =>
9595
['COMMENT[ comment <!]', 'COMMENT[> comment ]'],
9696
'<!-- <a href="foo"> -->' => ['COMMENT[ <a href="foo"> ]'],
97+
'<input type="checkbox" checked disabled foo>' => ['START[input]', "\tchecked: checked", "\tdisabled: disabled", "\tfoo: bar", "\ttype: checkbox" ],
9798
);
9899

99100
plan tests => @tests / 2;

0 commit comments

Comments
 (0)