diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-05-15 12:54:33 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-05-15 12:54:33 +0000 |
commit | d8b4bc529b8512223dc7ae3c80c5131257658402 (patch) | |
tree | e73a59df57661f13f2739fce5de5d903e94b469a /urpm/media.pm | |
parent | 15cc4ae32901ff2d8adddbd58953b695cdee4d5c (diff) | |
download | urpmi-d8b4bc529b8512223dc7ae3c80c5131257658402.tar urpmi-d8b4bc529b8512223dc7ae3c80c5131257658402.tar.gz urpmi-d8b4bc529b8512223dc7ae3c80c5131257658402.tar.bz2 urpmi-d8b4bc529b8512223dc7ae3c80c5131257658402.tar.xz urpmi-d8b4bc529b8512223dc7ae3c80c5131257658402.zip |
- urpmi.addmedia, urpmi.update:
o check downloaded synthesis is not invalid HTML code (#39918)
(useful for servers not returning a valid HTTP error)
Diffstat (limited to 'urpm/media.pm')
-rw-r--r-- | urpm/media.pm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/urpm/media.pm b/urpm/media.pm index 82338da8..5d788f5a 100644 --- a/urpm/media.pm +++ b/urpm/media.pm @@ -1230,7 +1230,7 @@ sub get_synthesis__remote { my $ok = try__maybe_mirrorlist($urpm, $medium, sub { urpm::download::sync($urpm, $medium, [ _url_with_synthesis($medium) ], quiet => $quiet, callback => $callback) && - file_size(cachedir_with_synthesis($urpm, $medium)) >= 20; + _check_synthesis(cachedir_with_synthesis($urpm, $medium)); }); if (!$ok) { chomp(my $err = $@); @@ -1239,6 +1239,18 @@ sub get_synthesis__remote { $ok; } +sub _check_synthesis { + my ($synthesis_file) = @_; + + file_size($synthesis_file) >= 20 or return; + + # check first 2 lines do not contain typical html code + # this is useful for servers not returning a valid HTTP error (#39918) + open(my $F, '<', $synthesis_file) or return; + my $s = <$F>; $s .= <$F>; + $s !~ /<html>|<!DOCTYPE\s/i; +} + #- check copied/downloaded file has right signature. sub check_synthesis_md5sum { my ($urpm, $medium) = @_; @@ -1393,7 +1405,7 @@ sub _update_medium__parse_if_unmodified__remote { my $f = "$urpm->{cachedir}/partial/" . basename($url); $options->{force} and unlink $f; if (urpm::download::sync($urpm, $medium, [ $url ], - quiet => $options->{quiet}, callback => $options->{callback}) && file_size($f) >= 20) { + quiet => $options->{quiet}, callback => $options->{callback}) && _check_synthesis($f)) { $urpm->{log}(N("found probed synthesis as %s", $url)); 1; } else { |