text
stringlengths
0
357
{
/* unquoted attribute value, as the needed null-terminated may overwrite important characters, we'll create a copy */
beg_attr_value = p;
p += strcspn(p, XML_WS "/>"); /* get end of attribute value */
bak = *p;
*p = '\0';
char* temp = dc_strdup(beg_attr_value);
beg_attr_value_new = xml_decode(temp, ' ');
if (beg_attr_value_new!=temp) { free(temp); }
*p = bak;
}
}
else
{
beg_attr_value_new = dc_strdup(NULL);
}
/* add attribute */
if (attr_index < MAX_ATTR)
{
char* beg_attr_name_new = beg_attr_name;
int free_bits = (beg_attr_value_new != beg_attr_value)? FREE_VALUE : 0;
if (after_attr_name==p) {
/* take care not to overwrite the current pointer (happens eg. for `<tag attrWithoutValue>` */
bak = *after_attr_name;
*after_attr_name = '\0';
beg_attr_name_new = dc_strdup(beg_attr_name);
*after_attr_name = bak;
free_bits |= FREE_KEY;
}
else {
*after_attr_name = '\0';
}
dc_strlower_in_place(beg_attr_name_new);
attr[attr_index] = beg_attr_name_new;
attr[attr_index+1] = beg_attr_value_new;
attr[attr_index+2] = NULL; /* null-terminate list */
free_attr[attr_index>>1] = free_bits;
attr_index += 2;
}
}
while (isspace(*p)) { p++; } /* forward to attribute name beginning */
}
char bak = *after_tag_name; /* backup the character as it may be `/` or `>` which gets important downwards */
*after_tag_name = 0;
dc_strlower_in_place(beg_tag_name);
saxparser->starttag_cb(saxparser->userdata, beg_tag_name, attr);
*after_tag_name = bak;
/* self-closing tag */
p += strspn(p, XML_WS); /* skip whitespace before possible `/` */
if (*p=='/')
{
p++;
*after_tag_name = 0;
saxparser->endtag_cb(saxparser->userdata, beg_tag_name); /* already lowercase from starttag_cb()-call */
}
}
} /* end of processing start-tag */
p = strchr(p, '>');
if (p==NULL) { goto cleanup; } /* unclosed start-tag or end-tag */
p++;
} /* end of processing start-tag or end-tag */
last_text_start = p;
}
else
{
p++;
}
}
call_text_cb(saxparser, last_text_start, p - last_text_start, '&'); /* flush pending text */
cleanup:
do_free_attr(attr, free_attr);
free(buf_start);
}
```
Filename: dc_securejoin.c
```c
#include <stdarg.h>
#include <unistd.h>
#include "dc_context.h"
#include "dc_key.h"
#include "dc_apeerstate.h"
#include "dc_mimeparser.h"
#include "dc_mimefactory.h"
#include "dc_job.h"
#include "dc_token.h"