aboutsummaryrefslogtreecommitdiffstats
path: root/src/ls.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-02 01:26:15 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-02 01:26:15 +0000
commitefe8a04c70f1dde3c62e88f514433515631db858 (patch)
treed6ba8eb0acd4a299149596718cd4bfb6224f20f1 /src/ls.c
parentbef55ff3de4a16100b8115950c10f3cede755d3c (diff)
downloadmpd-efe8a04c70f1dde3c62e88f514433515631db858.tar.gz
mpd-efe8a04c70f1dde3c62e88f514433515631db858.tar.xz
mpd-efe8a04c70f1dde3c62e88f514433515631db858.zip
validate url's before adding to playlist
git-svn-id: https://svn.musicpd.org/mpd/trunk@1289 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c66
1 files changed, 59 insertions, 7 deletions
diff --git a/src/ls.c b/src/ls.c
index 285874585..f477d7fa2 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -22,6 +22,7 @@
#include "path.h"
#include "myfprintf.h"
#include "log.h"
+#include "utf8.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -41,17 +42,68 @@ char * dupAndStripPlaylistSuffix(char * file) {
return ret;
}
-int isRemoteUrl(char * url) {
- char * prefixes[] = {
- "http://",
- NULL
- };
+static char * remoteUrlPrefixes[] =
+{
+ "http://",
+ NULL
+};
+
+int isValidRemoteUtf8Url(char * utf8url) {
+ int ret = 0;
+ char * lat1 = utf8StrToLatin1Dup(utf8url);
+ char * temp;
+
+ if(!lat1) return 0;
+
+ switch(isRemoteUrl(lat1)) {
+ case 1:
+ ret = 1;
+ temp = lat1;
+ while(*temp) {
+ if((*temp >= 'a' && *temp <= 'z') ||
+ (*temp >= 'A' && *temp <= 'z') ||
+ (*temp >= '0' && *temp <= '9') ||
+ *temp == '$' ||
+ *temp == '-' ||
+ *temp == '.' ||
+ *temp == '+' ||
+ *temp == '!' ||
+ *temp == '*' ||
+ *temp == '\'' ||
+ *temp == '(' ||
+ *temp == ')' ||
+ *temp == ',' ||
+ *temp == '%' ||
+ *temp == '/' ||
+ *temp == ':' ||
+ *temp == '?' ||
+ *temp == ';' ||
+ *temp == '&' ||
+ *temp == '=')
+ {
+ }
+ else {
+ ret = 1;
+ break;
+ }
+ temp++;
+ }
+ break;
+ }
+
+ free(lat1);
+
+ return ret;
+}
- char ** urlPrefixes = prefixes;
+int isRemoteUrl(char * url) {
+ int count = 0;
+ char ** urlPrefixes = remoteUrlPrefixes;
while(*urlPrefixes) {
+ count++;
if(strncmp(*urlPrefixes,url,strlen(*urlPrefixes)) == 0) {
- return 1;
+ return count;
}
urlPrefixes++;
}