The attached patch adds unconditional URL decoding to the "urlSuffix"
part of the URL only.
I added this so I could have spaces in file names, though it has other
benefits. For one thing, since RTSP specifies that header info is to be
interpreted as UTF-8, it means we get Unicode file name support for free
on UTF-8 based OSes.
In anticipation of any argument as to whether we should do this
unconditionally, I refer you to RFC 2616 (HTTP 1.1) section 5.1.2, which
says hex decoding MUST be done. Since RTSP is specified as a kind of
logical extension to HTTP and doesn't otherwise specify how URIs are to
be processed, I suppose this means RTSP also must do URL hex decoding,
even if the URL doesn't specify a file name.
I further suppose that means we should be applying URL decoding to the
other parts of the URL. I don't need it, but all it would take to fix
that lack is to call urlDecode() on these other parts, too.
--- live/liveMedia/RTSPCommon.cpp.orig 2013-03-29 09:21:19.000000000 -0600
+++ live/liveMedia/RTSPCommon.cpp 2013-03-29 09:57:44.000000000 -0600
@@ -30,6 +30,30 @@
#define USE_SIGNALS 1
#endif
+static void urlDecode(char* url) {
+ char hex[3];
+ hex[2] = '\0';
+
+ char* cursor = url;
+ while (*cursor) {
+ if ((cursor[0] == '%') &&
+ cursor[1] && isxdigit(cursor[1]) &&
+ cursor[2] && isxdigit(cursor[2])) {
+ // saw a % followed by 2 hex digits, so copy literal hex value
+ // into URL, then advance cursor past it
+ memcpy(hex, cursor + 1, 2);
+ *url++ = char(strtol(hex, 0, 16));
+ cursor += 3;
+ }
+ else {
+ // normal character or bogus % expression, so just copy it
+ *url++ = *cursor++;
+ }
+ }
+
+ *url = '\0';
+}
+
Boolean parseRTSPRequestString(char const* reqStr,
unsigned reqStrSize,
char* resultCmdName,
@@ -114,6 +138,7 @@
while (k2 <= k1 - 1) resultURLPreSuffix[n++] = reqStr[k2++];
}
resultURLPreSuffix[n] = '\0';
+ urlDecode(resultURLPreSuffix);
i = k + 7; // to go past " RTSP/"
parseSucceeded = True;
_______________________________________________
live-devel mailing list
live-devel@lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel