Merge pull request 'df-xmldecode-patch' (#1) from df/tvdb:df-xmldecode-patch into master
Reviewed-on: #1
This commit is contained in:
commit
4d47fea182
2
Makefile
2
Makefile
|
@ -9,7 +9,7 @@ HDRS=
|
||||||
OBJS= $(SRCS:.c=.o)
|
OBJS= $(SRCS:.c=.o)
|
||||||
CC=gcc
|
CC=gcc
|
||||||
#CC=mipsel-linux-gcc
|
#CC=mipsel-linux-gcc
|
||||||
CFLAGS=-g
|
CFLAGS=-g -std=c99 -D_XOPEN_SOURCE=700
|
||||||
INCS=
|
INCS=
|
||||||
LIBS=-lsqlite3
|
LIBS=-lsqlite3
|
||||||
WARN=-pedantic -Wall -W -Wnested-externs -Wpointer-arith -Wno-long-long
|
WARN=-pedantic -Wall -W -Wnested-externs -Wpointer-arith -Wno-long-long
|
||||||
|
|
28
tvdb.c
28
tvdb.c
|
@ -51,23 +51,31 @@ unescape(char *txt)
|
||||||
char *p = txt;
|
char *p = txt;
|
||||||
int l = strlen(txt);
|
int l = strlen(txt);
|
||||||
|
|
||||||
while ((p = strchr(p, '&')))
|
for (; (p = strchr(p, '&')); p++)
|
||||||
{
|
{
|
||||||
HANDLE(""", '"', 5);
|
int ll = 0;
|
||||||
HANDLE("&", '&', 4);
|
unsigned char icode;
|
||||||
HANDLE("
", '\n', 4);
|
/* sscanf -> 1: the code was read; ll>0: ';' came next */
|
||||||
HANDLE("
", '\r', 4);
|
if ((1 == sscanf( p, "&#%hhu;%n", &icode, &ll) ||
|
||||||
p++;
|
1 == sscanf( p, "&#%*[xX]%hhx;%n", &icode, &ll)) &&
|
||||||
|
ll > 0) {
|
||||||
|
/* &#x<hex>;, &#<decimal>; */
|
||||||
|
HANDLE(p, (char)icode, ll-1);
|
||||||
|
} else {
|
||||||
|
HANDLE("&", '&', 4);
|
||||||
|
HANDLE(""", '"', 5);
|
||||||
|
HANDLE("'", '\'', 5);
|
||||||
|
HANDLE("<", '<', 3);
|
||||||
|
HANDLE(">", '>', 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p = txt;
|
for (p = txt; (p = memchr(p, '\xe2', l - (p - txt))); p++)
|
||||||
while ((p = memchr(p, '\xe2', l - (p - txt))))
|
{ /* curly apostrophe, en dash, curly quotes */
|
||||||
{
|
|
||||||
HANDLE("\xe2\x80\x99", '\'', 2);
|
HANDLE("\xe2\x80\x99", '\'', 2);
|
||||||
HANDLE("\xe2\x80\x93", '-', 2);
|
HANDLE("\xe2\x80\x93", '-', 2);
|
||||||
HANDLE("\xe2\x80\x9c", '"', 2);
|
HANDLE("\xe2\x80\x9c", '"', 2);
|
||||||
HANDLE("\xe2\x80\x9d", '"', 2);
|
HANDLE("\xe2\x80\x9d", '"', 2);
|
||||||
p++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((p = strpbrk(txt, "\n\r")))
|
if ((p = strpbrk(txt, "\n\r")))
|
||||||
|
|
Loading…
Reference in New Issue