Fixed the parse_args method.

This commit is contained in:
Relintai 2021-11-18 11:18:05 +01:00
parent 43a7185e23
commit ae3b14ad0c

View File

@ -119,34 +119,38 @@ void HTMLParserTag::parse_args(const String &args) {
} }
a.attribute = args.substr(i, equals_index - i); a.attribute = args.substr(i, equals_index - i);
//a.attribute.print();
//todo //todo
//a.trim(); //a.trim();
int next_char_index = equals_index + 1; int next_char_index = equals_index + 1;
if (next_char_index >= args.size()) {
//an attribute looks like this "... attrib="
attributes.push_back(a);
return;
}
//skip spaces //skip spaces
while (data[next_char_index] == ' ') { while (args[next_char_index] == ' ') {
++next_char_index; ++next_char_index;
if (next_char_index >= data.size()) { if (next_char_index >= args.size()) {
//an attribute looks like this "attrib= " //an attribute looks like this "... attrib= "
attributes.push_back(a); attributes.push_back(a);
return; return;
} }
} }
char c = data[next_char_index]; char c = args[next_char_index];
char find_char; char find_char = ' ';
if (c == '"' || c == '\'') { if (c == '"' || c == '\'') {
++next_char_index; ++next_char_index;
find_char = c; find_char = c;
} else {
find_char = ' ';
} }
int end_index = args.find(find_char, next_char_index); int end_index = args.find(find_char, next_char_index);
if (end_index == -1) { if (end_index == -1) {
@ -155,17 +159,13 @@ void HTMLParserTag::parse_args(const String &args) {
a.data = args.substr(next_char_index, args.size() - next_char_index - 1); a.data = args.substr(next_char_index, args.size() - next_char_index - 1);
attributes.push_back(a); attributes.push_back(a);
a.data.print();
return; return;
} }
a.data = args.substr(next_char_index, end_index - next_char_index - 1); a.data = args.substr(next_char_index, end_index - next_char_index);
attributes.push_back(a); attributes.push_back(a);
//a.data.print();
i = end_index + 1; i = end_index + 1;
printf("\n");
} }
} }