Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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>
  • Loading branch information...
commit c40e97e687c2f26559e815081e47a619ee5c91e6 1 parent ff7b860
@ntfreak authored
Showing with 21 additions and 0 deletions.
  1. +20 −0 utils.c
  2. +1 −0  utils.h
View
20 utils.c
@@ -207,6 +207,26 @@ modifyString(char * string, const char * before, const char * after)
}
char *
+unescape_tag(const char *tag, int force_alloc)
+{
+ char *esc_tag = NULL;
+
+ if( strstr(tag, "&amp;") || strstr(tag, "&lt;") || strstr(tag, "&gt;")
+ || strstr(tag, "&quot;") )
+ {
+ esc_tag = strdup(tag);
+ esc_tag = modifyString(esc_tag, "&amp;", "&");
+ esc_tag = modifyString(esc_tag, "&lt;", "<");
+ esc_tag = modifyString(esc_tag, "&gt;", ">");
+ esc_tag = modifyString(esc_tag, "&quot;", "\"");
+ }
+ else if( force_alloc )
+ esc_tag = strdup(tag);
+
+ return esc_tag;
+}
+
+char *
escape_tag(const char *tag, int force_alloc)
{
char *esc_tag = NULL;
View
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 *modifyString(char * string, const char * before, const char * after);
char *escape_tag(const char *tag, int force_alloc);
+char *unescape_tag(const char *tag, int force_alloc);
void strip_ext(char * name);
/* Metadata functions */
Please sign in to comment.
Something went wrong with that request. Please try again.