static int
check_file( const char *url )
{
- if (url && !strncmp(url, "file://", 7))
- return access(url + 7, R_OK) == 0;
+ if (url && !strncmp(url, "file://", 7)) {
+ char *s = tvh_strdupa(url + 7);
+ http_deescape(s);
+ return access(s, R_OK) == 0;
+ }
return 1;
}
return http_path_add_modify(path, opaque, callback, accessmask, NULL);
}
-/**
- * De-escape HTTP URL
- */
-void
-http_deescape(char *s)
-{
- char v, *d = s;
-
- while(*s) {
- if(*s == '+') {
- *d++ = ' ';
- s++;
- } else if(*s == '%') {
- s++;
- switch(*s) {
- case '0' ... '9':
- v = (*s - '0') << 4;
- break;
- case 'a' ... 'f':
- v = (*s - 'a' + 10) << 4;
- break;
- case 'A' ... 'F':
- v = (*s - 'A' + 10) << 4;
- break;
- default:
- *d = 0;
- return;
- }
- s++;
- switch(*s) {
- case '0' ... '9':
- v |= (*s - '0');
- break;
- case 'a' ... 'f':
- v |= (*s - 'a' + 10);
- break;
- case 'A' ... 'F':
- v |= (*s - 'A' + 10);
- break;
- default:
- *d = 0;
- return;
- }
- s++;
-
- *d++ = v;
- } else {
- *d++ = *s++;
- }
- }
- *d = 0;
-}
-
-
/**
* Parse arguments of a HTTP GET url, not perfect, but works for us
*/
int http_access_verify_channel(http_connection_t *hc, int mask,
struct channel *ch);
-void http_deescape(char *s);
-
void http_parse_args(http_arg_list_t *list, char *args);
char *http_get_hostpath(http_connection_t *hc);
/* URL decoding */
char to_hex(char code);
char *url_encode(const char *str);
+void http_deescape(char *str);
int mpegts_word_count(const uint8_t *tsb, int len, uint32_t mask);
return buf;
}
+/**
+ * De-escape HTTP URL
+ */
+void
+http_deescape(char *s)
+{
+ char v, *d = s;
+
+ while(*s) {
+ if(*s == '+') {
+ *d++ = ' ';
+ s++;
+ } else if(*s == '%') {
+ s++;
+ switch(*s) {
+ case '0' ... '9':
+ v = (*s - '0') << 4;
+ break;
+ case 'a' ... 'f':
+ v = (*s - 'a' + 10) << 4;
+ break;
+ case 'A' ... 'F':
+ v = (*s - 'A' + 10) << 4;
+ break;
+ default:
+ *d = 0;
+ return;
+ }
+ s++;
+ switch(*s) {
+ case '0' ... '9':
+ v |= (*s - '0');
+ break;
+ case 'a' ... 'f':
+ v |= (*s - 'a' + 10);
+ break;
+ case 'A' ... 'F':
+ v |= (*s - 'A' + 10);
+ break;
+ default:
+ *d = 0;
+ return;
+ }
+ s++;
+
+ *d++ = v;
+ } else {
+ *d++ = *s++;
+ }
+ }
+ *d = 0;
+}
+
/*
*
*/