X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fxscreensaver-text;h=1b55832d92c49422ba6675da8179d7388719f1a1;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hp=fa5e20c149fbc4a7ba51d29de6052fe52c2abbe9;hpb=d5186197bc394e10a4402f7f6d23fbb14103bc50;p=xscreensaver diff --git a/driver/xscreensaver-text b/driver/xscreensaver-text index fa5e20c1..1b55832d 100755 --- a/driver/xscreensaver-text +++ b/driver/xscreensaver-text @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright © 2005-2014 Jamie Zawinski +# Copyright © 2005-2016 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that @@ -37,7 +37,7 @@ use Text::Wrap qw(wrap); use bytes; my $progname = $0; $progname =~ s@.*/@@g; -my ($version) = ('$Revision: 1.37 $' =~ m/\s(\d[.\d]+)\s/s); +my ($version) = ('$Revision: 1.41 $' =~ m/\s(\d[.\d]+)\s/s); my $verbose = 0; my $http_proxy = undef; @@ -47,7 +47,7 @@ my $text_mode = 'date'; my $text_literal = ''; my $text_file = ''; my $text_program = ''; -my $text_url = 'http://en.wikipedia.org/w/index.php?title=Special:NewPages&feed=rss'; +my $text_url = 'https://en.wikipedia.org/w/index.php?title=Special:NewPages&feed=rss'; # Default URL needs to be set and match what's in OSX/XScreenSaverView.m my $wrap_columns = undef; @@ -190,7 +190,10 @@ sub get_cocoa_prefs($) { $text_mode = $v if defined ($v); # The "textMode" pref is set to a number instead of a string because I - # can't figure out the black magic to make Cocoa bindings work right. + # couldn't figure out the black magic to make Cocoa bindings work right. + # + # Update: as of 5.33, Cocoa writes strings instead of numbers, but + # pre-existing saved preferences might still have numbers in them. # if ($text_mode eq '0') { $text_mode = 'date'; } elsif ($text_mode eq '1') { $text_mode = 'literal'; } @@ -274,6 +277,8 @@ sub which($) { sub output() { + binmode (STDOUT, ($latin1_p ? ':raw' : ':utf8')); + # Do some basic sanity checking (null text, null file names, etc.) # if (($text_mode eq 'literal' && $text_literal =~ m/^\s*$/i) || @@ -470,8 +475,8 @@ sub reformat_html($$) { # Try to omit all tables, since they're impossible to read as text. # - 1 while (s/{{[^{}]*}}/ /gs); # {{ ... }} - 1 while (s/{\|.*?\|}/\n\n/gs); # {| ... |} + 1 while (s/\{\{[^{}]*}}/ /gs); # {{ ... }} + 1 while (s/\{\|.*?\|\}/\n\n/gs); # {| ... |} 1 while (s/\|-.*?\|/ /gs); # |- ... | (table cell) # Convert anchors to something more readable. @@ -656,16 +661,21 @@ sub reformat_text($) { sub set_proxy($) { my ($ua) = @_; - if (!defined($ENV{http_proxy}) && !defined($ENV{HTTP_PROXY})) { - my $proxy_data = `scutil --proxy 2>/dev/null`; - my ($server) = ($proxy_data =~ m/\bHTTPProxy\s*:\s*([^\s]+)/s); - my ($port) = ($proxy_data =~ m/\bHTTPPort\s*:\s*([^\s]+)/s); - if ($server) { + my $proxy_data = `scutil --proxy 2>/dev/null`; + foreach my $proto ('http', 'https') { + my ($server) = ($proxy_data =~ m/\b${proto}Proxy\s*:\s*([^\s]+)/si); + my ($port) = ($proxy_data =~ m/\b${proto}Port\s*:\s*([^\s]+)/si); + my ($enable) = ($proxy_data =~ m/\b${proto}Enable\s*:\s*([^\s]+)/si); + + if ($server && $enable) { # Note: this ignores the "ExceptionsList". - $ENV{http_proxy} = "http://" . $server . ($port ? ":$port" : "") . "/"; - print STDERR "$progname: MacOS proxy: $ENV{http_proxy}\n" - if ($verbose > 2) - } + my $proto2 = 'http'; + $ENV{"${proto}_proxy"} = ("${proto2}://" . $server . + ($port ? ":$port" : "") . "/"); + print STDERR "$progname: MacOS $proto proxy: " . + $ENV{"${proto}_proxy"} . "\n" + if ($verbose > 2); + } } $ua->env_proxy();