+static void trim_double_dot_url(char *buf, const char *rel, int size)
+{
+ const char *p = rel;
+ const char *root = rel;
+ char tmp_path[MAX_URL_SIZE] = {0, };
+ char *sep;
+ char *node;
+
+ /* Get the path root of the url which start by "://" */
+ if (p && (sep = strstr(p, "://"))) {
+ sep += 3;
+ root = strchr(sep, '/');
+ }
+
+ /* set new current position if the root node is changed */
+ p = root;
+ while (p && (node = strstr(p, ".."))) {
+ av_strlcat(tmp_path, p, node - p + strlen(tmp_path));
+ p = node + 3;
+ sep = strrchr(tmp_path, '/');
+ if (sep)
+ sep[0] = '\0';
+ else
+ tmp_path[0] = '\0';
+ }
+
+ if (!av_stristart(p, "/", NULL) && root != rel)
+ av_strlcat(tmp_path, "/", size);
+
+ av_strlcat(tmp_path, p, size);
+ /* start set buf after temp path process. */
+ av_strlcpy(buf, rel, root - rel + 1);
+
+ if (!av_stristart(tmp_path, "/", NULL) && root != rel)
+ av_strlcat(buf, "/", size);
+
+ av_strlcat(buf, tmp_path, size);
+}
+