diff options
author | Eric Wong <e@80x24.org> | 2022-08-29 09:26:44 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-08-29 19:05:53 +0000 |
commit | d03cb41b664aa6cd72fd87f7f88a54e80b976960 (patch) | |
tree | be20ba7e23764c2430b19c8007335e73e77b25a7 /lib/PublicInbox/ViewDiff.pm | |
parent | 6f5b238bae5c88b2b9b2fdf7834e17e78a33abd2 (diff) | |
download | public-inbox-d03cb41b664aa6cd72fd87f7f88a54e80b976960.tar.gz |
This also includes some glossary definitions to help users unfamiliar with git understand the relationship between trees and blobs.
Diffstat (limited to 'lib/PublicInbox/ViewDiff.pm')
-rw-r--r-- | lib/PublicInbox/ViewDiff.pm | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm index 8c1853e6..f16c7229 100644 --- a/lib/PublicInbox/ViewDiff.pm +++ b/lib/PublicInbox/ViewDiff.pm @@ -10,12 +10,11 @@ package PublicInbox::ViewDiff; use strict; use v5.10.1; use parent qw(Exporter); -our @EXPORT_OK = qw(flush_diff); +our @EXPORT_OK = qw(flush_diff uri_escape_path); use URI::Escape qw(uri_escape_utf8); use PublicInbox::Hval qw(ascii_html to_attr); use PublicInbox::Git qw(git_unquote); -my $UNSAFE = "^A-Za-z0-9\-\._~/"; # '/' + $URI::Escape::Unsafe{RFC3986} my $OID_NULL = '0{7,}'; my $OID_BLOB = '[a-f0-9]{7,}'; my $LF = qr!\n!; @@ -41,6 +40,11 @@ our $EXTRACT_DIFFS = qr/( ^\+{3}\x20($FN)$LF)/msx; our $IS_OID = qr/\A$OID_BLOB\z/s; +sub uri_escape_path { + # '/' + $URI::Escape::Unsafe{RFC3986} + uri_escape_utf8($_[0], "^A-Za-z0-9\-\._~/"); +} + # link to line numbers in blobs sub diff_hunk ($$$$) { my ($dst, $dctx, $ca, $cb) = @_; @@ -123,14 +127,14 @@ sub diff_header ($$$) { $pa = (split(m'/', git_unquote($pa), 2))[1] if $pa ne '/dev/null'; $pb = (split(m'/', git_unquote($pb), 2))[1] if $pb ne '/dev/null'; if ($pa eq $pb && $pb ne '/dev/null') { - $dctx->{Q} = "?b=".uri_escape_utf8($pb, $UNSAFE); + $dctx->{Q} = '?b='.uri_escape_path($pb); } else { my @q; if ($pb ne '/dev/null') { - push @q, 'b='.uri_escape_utf8($pb, $UNSAFE); + push @q, 'b='.uri_escape_path($pb); } if ($pa ne '/dev/null') { - push @q, 'a='.uri_escape_utf8($pa, $UNSAFE); + push @q, 'a='.uri_escape_path($pa); } $dctx->{Q} = '?'.join('&', @q); } |