From df8d80b50cc092a27a92b37b5b1709c58d883d53 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 9 Apr 2021 13:33:34 +0200 Subject: HAFAS->get_polyline_p: Do not leak credentials in error messages --- lib/DBInfoscreen/Helper/HAFAS.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/DBInfoscreen/Helper') diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm index 249d308..0a98e73 100644 --- a/lib/DBInfoscreen/Helper/HAFAS.pm +++ b/lib/DBInfoscreen/Helper/HAFAS.pm @@ -385,12 +385,15 @@ sub get_polyline_p { my $api = $self->{api}; my $url = "${api}/trips/${trip_id}?lineName=${line}&polyline=true"; + my $log_url = $url; my $cache = $self->{realtime_cache}; my $promise = Mojo::Promise->new; + $log_url =~ s{://\K[^:]+:[^@]+\@}{***@}; + if ( my $content = $cache->thaw($url) ) { $promise->resolve($content); - $self->{log}->debug("GET $url (cached)"); + $self->{log}->debug("GET $log_url (cached)"); return $promise; } @@ -401,14 +404,14 @@ sub get_polyline_p { if ( my $err = $tx->error ) { $self->{log}->warn( -"hafas->get_polyline_p($url): HTTP $err->{code} $err->{message}" +"hafas->get_polyline_p($log_url): HTTP $err->{code} $err->{message}" ); $promise->reject( - "GET $url returned HTTP $err->{code} $err->{message}"); + "GET $log_url returned HTTP $err->{code} $err->{message}"); return; } - $self->{log}->debug("GET $url (OK)"); + $self->{log}->debug("GET $log_url (OK)"); my $json = decode_json( $tx->res->body ); my @coordinate_list; @@ -435,7 +438,7 @@ sub get_polyline_p { )->catch( sub { my ($err) = @_; - $self->{log}->debug("GET $url (error: $err)"); + $self->{log}->debug("GET $log_url (error: $err)"); $promise->reject($err); return; } -- cgit v1.2.3