winemenubuilder: Escape XML special characters in MIME types.
This commit is contained in:
parent
856dda3288
commit
e1e07b40ba
|
@ -730,6 +730,26 @@ static char* heap_printf(const char *format, ...)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void write_xml_text(FILE *file, const char *text)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; text[i]; i++)
|
||||||
|
{
|
||||||
|
if (text[i] == '&')
|
||||||
|
fputs("&", file);
|
||||||
|
else if (text[i] == '<')
|
||||||
|
fputs("<", file);
|
||||||
|
else if (text[i] == '>')
|
||||||
|
fputs(">", file);
|
||||||
|
else if (text[i] == '\'')
|
||||||
|
fputs("'", file);
|
||||||
|
else if (text[i] == '"')
|
||||||
|
fputs(""", file);
|
||||||
|
else
|
||||||
|
fputc(text[i], file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL create_directories(char *directory)
|
static BOOL create_directories(char *directory)
|
||||||
{
|
{
|
||||||
BOOL ret = TRUE;
|
BOOL ret = TRUE;
|
||||||
|
@ -1805,10 +1825,18 @@ static BOOL write_freedesktop_mime_type_entry(const char *packages_dir, const ch
|
||||||
{
|
{
|
||||||
fprintf(packageFile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
fprintf(packageFile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
||||||
fprintf(packageFile, "<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">\n");
|
fprintf(packageFile, "<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">\n");
|
||||||
fprintf(packageFile, " <mime-type type=\"%s\">\n", mime_type);
|
fprintf(packageFile, " <mime-type type=\"");
|
||||||
fprintf(packageFile, " <glob pattern=\"*%s\"/>\n", dot_extension);
|
write_xml_text(packageFile, mime_type);
|
||||||
|
fprintf(packageFile, "\">\n");
|
||||||
|
fprintf(packageFile, " <glob pattern=\"*");
|
||||||
|
write_xml_text(packageFile, dot_extension);
|
||||||
|
fprintf(packageFile, "\"/>\n");
|
||||||
if (comment)
|
if (comment)
|
||||||
fprintf(packageFile, " <comment>%s</comment>\n", comment);
|
{
|
||||||
|
fprintf(packageFile, " <comment>");
|
||||||
|
write_xml_text(packageFile, comment);
|
||||||
|
fprintf(packageFile, "</comment>\n");
|
||||||
|
}
|
||||||
fprintf(packageFile, " </mime-type>\n");
|
fprintf(packageFile, " </mime-type>\n");
|
||||||
fprintf(packageFile, "</mime-info>\n");
|
fprintf(packageFile, "</mime-info>\n");
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
Loading…
Reference in New Issue