aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-07-03 00:18:06 +0200
committerdec05eba <dec05eba@protonmail.com>2021-07-03 00:18:06 +0200
commit41206f68eb257e788a2d038e25f01d9deb7d37af (patch)
tree00aae0721a00854adbfa0630e56051c81f1559f2 /src
parentd8132eeb7337b410a46fcf64ae0f6dacbe52cf33 (diff)
Strip whitespace for attribute values as well
Diffstat (limited to 'src')
-rw-r--r--src/HtmlSearch.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/HtmlSearch.c b/src/HtmlSearch.c
index 89ee326..03d7e3a 100644
--- a/src/HtmlSearch.c
+++ b/src/HtmlSearch.c
@@ -329,22 +329,6 @@ static int html_parse_callback(HtmlParser *html_parser, HtmlParseType parse_type
return 0;
}
-QuickMediaStringView quickmedia_html_node_get_attribute_value(QuickMediaMatchNode *self, const char *attribute_name) {
- QuickMediaStringView attr_name;
- attr_name.data = attribute_name;
- attr_name.size = strlen(attribute_name);
-
- QuickMediaHtmlAttribute *attr = get_attribute_by_name(self->node, attr_name);
- if(attr) {
- return attr->value;
- } else {
- QuickMediaStringView attr_value;
- attr_value.data = NULL;
- attr_value.size = 0;
- return attr_value;
- }
-}
-
static int is_whitespace(int c) {
switch(c) {
case ' ':
@@ -384,6 +368,24 @@ static void strip(const char *str, size_t size, const char **output_str, size_t
rstrip(*output_str, *output_size, output_size, strip_filter_func);
}
+QuickMediaStringView quickmedia_html_node_get_attribute_value(QuickMediaMatchNode *self, const char *attribute_name) {
+ QuickMediaStringView attr_name;
+ attr_name.data = attribute_name;
+ attr_name.size = strlen(attribute_name);
+
+ QuickMediaHtmlAttribute *attr = get_attribute_by_name(self->node, attr_name);
+ if(attr) {
+ QuickMediaStringView attr_value = attr->value;
+ strip(attr_value.data, attr_value.size, &attr_value.data, &attr_value.size, is_whitespace);
+ return attr_value;
+ } else {
+ QuickMediaStringView attr_value;
+ attr_value.data = NULL;
+ attr_value.size = 0;
+ return attr_value;
+ }
+}
+
static int merge_inner_text(QuickMediaHtmlNode *node, QuickMediaString *str) {
if(node->is_tag) {
int newline = 0;