| 654 | } |
| 655 | |
| 656 | static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, |
| 657 | AVDictionary **opts, AVDictionary *opts2, int *is_http_out) |
| 658 | { |
| 659 | HLSContext *c = s->priv_data; |
| 660 | AVDictionary *tmp = NULL; |
| 661 | const char *proto_name = NULL; |
| 662 | int ret; |
| 663 | int is_http = 0; |
| 664 | |
| 665 | if (av_strstart(url, "crypto", NULL)) { |
| 666 | if (url[6] == '+' || url[6] == ':') |
| 667 | proto_name = avio_find_protocol_name(url + 7); |
| 668 | } else if (av_strstart(url, "data", NULL)) { |
| 669 | if (url[4] == '+' || url[4] == ':') |
| 670 | proto_name = avio_find_protocol_name(url + 5); |
| 671 | } |
| 672 | |
| 673 | if (!proto_name) |
| 674 | proto_name = avio_find_protocol_name(url); |
| 675 | |
| 676 | if (!proto_name) |
| 677 | return AVERROR_INVALIDDATA; |
| 678 | |
| 679 | // only http(s) & file are allowed |
| 680 | if (av_strstart(proto_name, "file", NULL)) { |
| 681 | if (strcmp(c->allowed_extensions, "ALL") && !av_match_ext(url, c->allowed_extensions)) { |
| 682 | av_log(s, AV_LOG_ERROR, |
| 683 | "Filename extension of \'%s\' is not a common multimedia extension, blocked for security reasons.\n" |
| 684 | "If you wish to override this adjust allowed_extensions, you can set it to \'ALL\' to allow all\n", |
| 685 | url); |
| 686 | return AVERROR_INVALIDDATA; |
| 687 | } |
| 688 | } else if (av_strstart(proto_name, "http", NULL)) { |
| 689 | is_http = 1; |
| 690 | } else if (av_strstart(proto_name, "data", NULL)) { |
| 691 | ; |
| 692 | } else |
| 693 | return AVERROR_INVALIDDATA; |
| 694 | |
| 695 | if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] == ':') |
| 696 | ; |
| 697 | else if (av_strstart(url, "crypto", NULL) && !strncmp(proto_name, url + 7, strlen(proto_name)) && url[7 + strlen(proto_name)] == ':') |
| 698 | ; |
| 699 | else if (av_strstart(url, "data", NULL) && !strncmp(proto_name, url + 5, strlen(proto_name)) && url[5 + strlen(proto_name)] == ':') |
| 700 | ; |
| 701 | else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5)) |
| 702 | return AVERROR_INVALIDDATA; |
| 703 | |
| 704 | av_dict_copy(&tmp, *opts, 0); |
| 705 | av_dict_copy(&tmp, opts2, 0); |
| 706 | |
| 707 | if (is_http && c->http_persistent && *pb) { |
| 708 | ret = open_url_keepalive(c->ctx, pb, url, &tmp); |
| 709 | if (ret == AVERROR_EXIT) { |
| 710 | av_dict_free(&tmp); |
| 711 | return ret; |
| 712 | } else if (ret < 0) { |
| 713 | if (ret != AVERROR_EOF) |
no test coverage detected