utils: add unescape_tag function
This is added to remove any escape chars from a string. This will be used in a pending patch, that correctly reads .nfo files that contain escape chars. Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
This commit is contained in:
parent
7e6b015b05
commit
f5ebc22eeb
20
utils.c
20
utils.c
@ -206,6 +206,26 @@ modifyString(char * string, const char * before, const char * after)
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
unescape_tag(const char *tag, int force_alloc)
|
||||||
|
{
|
||||||
|
char *esc_tag = NULL;
|
||||||
|
|
||||||
|
if( strstr(tag, "&") || strstr(tag, "<") || strstr(tag, ">")
|
||||||
|
|| strstr(tag, """) )
|
||||||
|
{
|
||||||
|
esc_tag = strdup(tag);
|
||||||
|
esc_tag = modifyString(esc_tag, "&", "&");
|
||||||
|
esc_tag = modifyString(esc_tag, "<", "<");
|
||||||
|
esc_tag = modifyString(esc_tag, ">", ">");
|
||||||
|
esc_tag = modifyString(esc_tag, """, "\"");
|
||||||
|
}
|
||||||
|
else if( force_alloc )
|
||||||
|
esc_tag = strdup(tag);
|
||||||
|
|
||||||
|
return esc_tag;
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
escape_tag(const char *tag, int force_alloc)
|
escape_tag(const char *tag, int force_alloc)
|
||||||
{
|
{
|
||||||
|
1
utils.h
1
utils.h
@ -36,6 +36,7 @@ char *strstrc(const char *s, const char *p, const char t);
|
|||||||
char *strcasestrc(const char *s, const char *p, const char t);
|
char *strcasestrc(const char *s, const char *p, const char t);
|
||||||
char *modifyString(char * string, const char * before, const char * after);
|
char *modifyString(char * string, const char * before, const char * after);
|
||||||
char *escape_tag(const char *tag, int force_alloc);
|
char *escape_tag(const char *tag, int force_alloc);
|
||||||
|
char *unescape_tag(const char *tag, int force_alloc);
|
||||||
void strip_ext(char * name);
|
void strip_ext(char * name);
|
||||||
|
|
||||||
/* Metadata functions */
|
/* Metadata functions */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user