summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-25 19:33:54 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-25 19:33:54 +0100
commit0b39142b67849cb20dffcdac48b2886a33968fbb (patch)
treed21da52e4c420deb6fd5d26c9b181a15e323e8a5
parent53a6a7faa01aa0c6a65ee875c7d59c2405278890 (diff)
prevent adding URIs with invalid characters
-rw-r--r--playlist.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/playlist.c b/playlist.c
index bce039b4..43d568fe 100644
--- a/playlist.c
+++ b/playlist.c
@@ -614,6 +614,8 @@ pl_insert_file (playItem_t *after, const char *fname, int *pabort, int (*cb)(pla
if (strncasecmp (fname, "file://", 7)) {
const char *p = fname;
int detect_on_access = 1;
+
+ // check if it's URI
for (; *p; p++) {
if (!strncmp (p, "://", 3)) {
break;
@@ -623,7 +625,18 @@ pl_insert_file (playItem_t *after, const char *fname, int *pabort, int (*cb)(pla
break;
}
}
+
if (detect_on_access && *p == ':') {
+ // check for wrong chars like CR/LF, TAB, etc
+ // they are not allowed and might lead to corrupt display in GUI
+ int32_t i = 0;
+ while (fname[i]) {
+ uint32_t c = u8_nextchar (fname, &i);
+ if (c < 0x20) {
+ return NULL;
+ }
+ }
+
playItem_t *it = pl_item_alloc ();
it->decoder = NULL;
it->fname = strdup (fname);