Fixes Ticket3791
Reviewed-by: "Reynaldo H. Verdejo Pinochet" <reynaldo@osg.samsung.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
... | ... |
@@ -164,6 +164,7 @@ typedef struct HTTPContext { |
164 | 164 |
char protocol[16]; |
165 | 165 |
char method[16]; |
166 | 166 |
char url[128]; |
167 |
+ char clean_url[128*7]; |
|
167 | 168 |
int buffer_size; |
168 | 169 |
uint8_t *buffer; |
169 | 170 |
int is_packetized; /* if true, the stream is packetized */ |
... | ... |
@@ -1920,6 +1921,34 @@ static inline void print_stream_params(AVIOContext *pb, FFServerStream *stream) |
1920 | 1920 |
avio_printf(pb, "</table>\n"); |
1921 | 1921 |
} |
1922 | 1922 |
|
1923 |
+static void clean_html(char *clean, int clean_len, char *dirty) |
|
1924 |
+{ |
|
1925 |
+ int i, o; |
|
1926 |
+ |
|
1927 |
+ for (o = i = 0; o+10 < clean_len && dirty[i];) { |
|
1928 |
+ int len = strspn(dirty+i, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*(),?/ :;%"); |
|
1929 |
+ if (len) { |
|
1930 |
+ if (o + len >= clean_len) |
|
1931 |
+ break; |
|
1932 |
+ memcpy(clean + o, dirty + i, len); |
|
1933 |
+ i += len; |
|
1934 |
+ o += len; |
|
1935 |
+ } else { |
|
1936 |
+ int c = dirty[i++]; |
|
1937 |
+ switch (c) { |
|
1938 |
+ case '&': av_strlcat(clean+o, "&" , clean_len - o); break; |
|
1939 |
+ case '<': av_strlcat(clean+o, "<" , clean_len - o); break; |
|
1940 |
+ case '>': av_strlcat(clean+o, ">" , clean_len - o); break; |
|
1941 |
+ case '\'': av_strlcat(clean+o, "'" , clean_len - o); break; |
|
1942 |
+ case '\"': av_strlcat(clean+o, """ , clean_len - o); break; |
|
1943 |
+ default: av_strlcat(clean+o, "☹", clean_len - o); break; |
|
1944 |
+ } |
|
1945 |
+ o += strlen(clean+o); |
|
1946 |
+ } |
|
1947 |
+ } |
|
1948 |
+ clean[o] = 0; |
|
1949 |
+} |
|
1950 |
+ |
|
1923 | 1951 |
static void compute_status(HTTPContext *c) |
1924 | 1952 |
{ |
1925 | 1953 |
HTTPContext *c1; |
... | ... |
@@ -2107,7 +2136,7 @@ static void compute_status(HTTPContext *c) |
2107 | 2107 |
current_bandwidth, config.max_bandwidth); |
2108 | 2108 |
|
2109 | 2109 |
avio_printf(pb, "<table>\n"); |
2110 |
- avio_printf(pb, "<tr><th>#<th>File<th>IP<th>Proto<th>State<th>Target " |
|
2110 |
+ avio_printf(pb, "<tr><th>#<th>File<th>IP<th>URL<th>Proto<th>State<th>Target " |
|
2111 | 2111 |
"bit/s<th>Actual bit/s<th>Bytes transferred\n"); |
2112 | 2112 |
c1 = first_http_ctx; |
2113 | 2113 |
i = 0; |
... | ... |
@@ -2127,10 +2156,13 @@ static void compute_status(HTTPContext *c) |
2127 | 2127 |
|
2128 | 2128 |
i++; |
2129 | 2129 |
p = inet_ntoa(c1->from_addr.sin_addr); |
2130 |
- avio_printf(pb, "<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s" |
|
2130 |
+ clean_html(c1->clean_url, sizeof(c1->clean_url), c1->url); |
|
2131 |
+ avio_printf(pb, "<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s<td>%s" |
|
2131 | 2132 |
"<td align=right>", |
2132 | 2133 |
i, c1->stream ? c1->stream->filename : "", |
2133 |
- c1->state == HTTPSTATE_RECEIVE_DATA ? "(input)" : "", p, |
|
2134 |
+ c1->state == HTTPSTATE_RECEIVE_DATA ? "(input)" : "", |
|
2135 |
+ p, |
|
2136 |
+ c1->clean_url, |
|
2134 | 2137 |
c1->protocol, http_state[c1->state]); |
2135 | 2138 |
fmt_bytecount(pb, bitrate); |
2136 | 2139 |
avio_printf(pb, "<td align=right>"); |
... | ... |
@@ -28,7 +28,7 @@ sleep 2 |
28 | 28 |
fi |
29 | 29 |
do_md5sum ff-$file >>ffserver.regression |
30 | 30 |
done |
31 |
- wget $WGET_OPTIONS -O - teststat.html http://localhost:9999/teststat.html > ff-stat 2>/dev/null |
|
31 |
+ wget $WGET_OPTIONS -O - 'http://localhost:9999/teststat.html?abc' > ff-stat 2>/dev/null |
|
32 | 32 |
do_md5sum ff-stat >>ffserver.regression |
33 | 33 |
) |
34 | 34 |
kill $FFSERVER_PID |
... | ... |
@@ -8,4 +8,4 @@ d41d8cd98f00b204e9800998ecf8427e *ff-test_l.rm |
8 | 8 |
4c887dfc1dd0f6ea1a3a2be6dd32e495 *ff-test.jpg |
9 | 9 |
1d04b73b04aad27793cc762d5afabac1 *ff-test_small.jpg |
10 | 10 |
bc36c40ee34ebee6ffe50f3094aab733 *ff-test.mjpg |
11 |
-9b72c3d6d89a038fa141fe636baa2c0e *ff-stat |
|
11 |
+56c8b3ba2c4f3eebfa6d2a895e042ee3 *ff-stat |