whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: $SAFE no longer useful
Date Mon, 21 Sep 2020 10:16:04 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new fd2b0b6  $SAFE no longer useful
fd2b0b6 is described below

commit fd2b0b64081a68a47feaa2c97285a2b01a6fa848
Author: Sebb <sebb@apache.org>
AuthorDate: Mon Sep 21 11:15:53 2020 +0100

    $SAFE no longer useful
---
 tools/download_check.rb | 35 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 23 deletions(-)

diff --git a/tools/download_check.rb b/tools/download_check.rb
index 2d91251..f9b4c6c 100755
--- a/tools/download_check.rb
+++ b/tools/download_check.rb
@@ -20,8 +20,6 @@ Checks performed: (F=fatal, E=error, W=warn)
 TBA
 =end
 
-$SAFE = 1
-
 $CLI = false
 $VERBOSE = false
 
@@ -124,15 +122,20 @@ def displayHTML
   _h4_ 'F: fatal, E: Error, W: warning, I: info (success)'
 end
 
-# get an HTTP URL
-def HEAD(url)
-  puts ">> HEAD #{url}" if $VERBOSE
-  url.untaint
+def check_url(url)
   uri = URI.parse(url)
   unless uri.scheme
     W "No scheme for URL #{url}, assuming http"
     uri = URI.parse("http:"+url)
   end
+  return uri if %w{http https}.include? uri.scheme
+  raise ArgumentError.new("Unexpected url: #{url}")
+end
+
+# get an HTTP URL
+def HEAD(url)
+  puts ">> HEAD #{url}" if $VERBOSE
+  uri = check_url(url)
   http = Net::HTTP.new(uri.host, uri.port)
   http.use_ssl = uri.scheme == 'https'
   request = Net::HTTP::Head.new(uri.request_uri)
@@ -142,16 +145,11 @@ end
 # get an HTTP URL=> response
 def GET(url)
   puts ">> GET #{url}" if $VERBOSE
-  url.untaint
-  uri = URI.parse(url).untaint
-  unless uri.scheme
-    W "No scheme for URL #{url}, assuming http"
-    uri = URI.parse("http:"+url).untaint
-  end
+  uri = check_url(url)
   http = Net::HTTP.new(uri.host, uri.port)
   http.use_ssl = uri.scheme == 'https'
   request = Net::HTTP::Get.new(uri.request_uri)
-  http.request(request.untaint)
+  http.request(request)
 end
 
 # Check page exists
@@ -321,15 +319,7 @@ def _checkDownloadPage(path, tlp, version)
   end
 
   # check the main body
-  if path.start_with? 'http'
-    body = check_page(path)
-  else
-    file = path
-    if file.start_with? '~'
-      file = ENV['HOME'] + file[1..-1]
-    end
-    body = File.read(file.untaint)
-  end
+  body = check_page(path)
   
   return unless body
 
@@ -644,7 +634,6 @@ end
 
 if __FILE__ == $0
   $CLI = true
-  $SAFE = 0
   $VERBOSE =true
   $ALWAYS_CHECK_LINKS = ARGV.delete '--always'
   $NO_CHECK_LINKS = ARGV.delete '--nolinks'


Mime
View raw message