user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 1/3] t/watch_maildir: support non-master default branch
@ 2021-10-24 21:43 Thomas Weißschuh
  2021-10-24 21:43 ` [PATCH 2/3] t/git: " Thomas Weißschuh
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Weißschuh @ 2021-10-24 21:43 UTC (permalink / raw)
  To: meta; +Cc: Thomas Weißschuh

---
 t/watch_maildir.t | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/t/watch_maildir.t b/t/watch_maildir.t
index 6399fb7c..e0719f54 100644
--- a/t/watch_maildir.t
+++ b/t/watch_maildir.t
@@ -15,6 +15,7 @@ use_ok 'PublicInbox::Watch';
 use_ok 'PublicInbox::Emergency';
 my $cfgpfx = "publicinbox.test";
 my $addr = 'test-public@example.com';
+my $default_branch = PublicInbox::Import::default_branch;
 PublicInbox::Import::init_bare($git_dir);
 
 my $msg = <<EOF;
@@ -64,7 +65,7 @@ EOF
 my $cfg = PublicInbox::Config->new($cfg_path);
 PublicInbox::Watch->new($cfg)->scan('full');
 my $git = PublicInbox::Git->new($git_dir);
-my @list = $git->qx(qw(rev-list refs/heads/master));
+my @list = $git->qx('rev-list', $default_branch);
 is(scalar @list, 1, 'one revision in rev-list');
 
 my $write_spam = sub {
@@ -80,9 +81,9 @@ my $write_spam = sub {
 $write_spam->();
 is(unlink(glob("$maildir/new/*")), 1, 'unlinked old spam');
 PublicInbox::Watch->new($cfg)->scan('full');
-@list = $git->qx(qw(rev-list refs/heads/master));
+@list = $git->qx('rev-list', $default_branch);
 is(scalar @list, 2, 'two revisions in rev-list');
-@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
+@list = $git->qx('ls-tree', '-r', '--name-only', $default_branch);
 is(scalar @list, 0, 'tree is empty');
 is(unlink(glob("$spamdir/cur/*")), 1, 'unlinked trained spam');
 
@@ -94,7 +95,7 @@ the body of a message to majordomo\@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html\n);
 	PublicInbox::Emergency->new($maildir)->prepare(\$msg);
 	PublicInbox::Watch->new($cfg)->scan('full');
-	@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
+	@list = $git->qx('ls-tree', '-r', '--name-only', $default_branch);
 	is(scalar @list, 1, 'tree has one file');
 	my $mref = $git->cat_file('HEAD:'.$list[0]);
 	like($$mref, qr/something\n\z/s, 'message scrubbed on import');
@@ -102,9 +103,9 @@ More majordomo info at  http://vger.kernel.org/majordomo-info.html\n);
 	is(unlink(glob("$maildir/new/*")), 1, 'unlinked spam');
 	$write_spam->();
 	PublicInbox::Watch->new($cfg)->scan('full');
-	@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
+	@list = $git->qx('ls-tree', '-r', '--name-only', $default_branch);
 	is(scalar @list, 0, 'tree is empty');
-	@list = $git->qx(qw(rev-list refs/heads/master));
+	@list = $git->qx('rev-list', $default_branch);
 	is(scalar @list, 4, 'four revisions in rev-list');
 	is(unlink(glob("$spamdir/cur/*")), 1, 'unlinked trained spam');
 }
@@ -120,7 +121,7 @@ More majordomo info at  http://vger.kernel.org/majordomo-info.html\n);
 		local $SIG{__WARN__} = sub {}; # quiet spam check warning
 		PublicInbox::Watch->new($cfg)->scan('full');
 	}
-	@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
+	@list = $git->qx('ls-tree', '-r', '--name-only', $default_branch);
 	is(scalar @list, 0, 'tree has no files spamc checked');
 	is(unlink(glob("$maildir/new/*")), 1);
 }
@@ -132,16 +133,16 @@ More majordomo info at  http://vger.kernel.org/majordomo-info.html\n);
 	local $ENV{PATH} = $main_path;
 	PublicInbox::Emergency->new($maildir)->prepare(\$msg);
 	$cfg->{'publicinboxwatch.spamcheck'} = 'spamc';
-	@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
+	@list = $git->qx('ls-tree', '-r', '--name-only', $default_branch);
 	PublicInbox::Watch->new($cfg)->scan('full');
-	@list = $git->qx(qw(ls-tree -r --name-only refs/heads/master));
+	@list = $git->qx('ls-tree', '-r', '--name-only', $default_branch);
 	is(scalar @list, 1, 'tree has one file after spamc checked');
 
 	# XXX: workaround some weird caching/memoization in cat-file,
 	# shouldn't be an issue in real-world use, though...
 	$git = PublicInbox::Git->new($git_dir);
 
-	my $mref = $git->cat_file('refs/heads/master:'.$list[0]);
+	my $mref = $git->cat_file($default_branch.':'.$list[0]);
 	like($$mref, qr/something\n\z/s, 'message scrubbed on import');
 }
 

base-commit: f658918dcc5200b563beea6e1ea3411e89726cb4
-- 
2.33.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] t/git: support non-master default branch
  2021-10-24 21:43 [PATCH 1/3] t/watch_maildir: support non-master default branch Thomas Weißschuh
@ 2021-10-24 21:43 ` Thomas Weißschuh
  2021-10-24 21:43   ` [PATCH 3/3] mbox: Specify encoding for raw message display Thomas Weißschuh
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Weißschuh @ 2021-10-24 21:43 UTC (permalink / raw)
  To: meta; +Cc: Thomas Weißschuh

---
 t/git.t | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/git.t b/t/git.t
index 08b4a918..56fc8d95 100644
--- a/t/git.t
+++ b/t/git.t
@@ -9,7 +9,7 @@ use POSIX qw(strftime);
 use PublicInbox::Git;
 
 {
-	PublicInbox::Import::init_bare($dir);
+	PublicInbox::Import::init_bare($dir, 'master');
 	my $fi_data = './t/git.fast-import-data';
 	open my $fh, '<', $fi_data or die
 		"fast-import data readable (or run test at top level: $!";
-- 
2.33.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] mbox: Specify encoding for raw message display
  2021-10-24 21:43 ` [PATCH 2/3] t/git: " Thomas Weißschuh
@ 2021-10-24 21:43   ` Thomas Weißschuh
  2021-10-25  0:08     ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Weißschuh @ 2021-10-24 21:43 UTC (permalink / raw)
  To: meta; +Cc: Thomas Weißschuh

---
 lib/PublicInbox/Mbox.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index dede4825..1e30e4ea 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -58,10 +58,10 @@ sub res_hdr ($$) {
 	my @hdr = ('Content-Type');
 	if ($ctx->{ibx}->{obfuscate}) {
 		# obfuscation is stupid, but maybe scrapers are, too...
-		push @hdr, 'application/mbox';
+		push @hdr, 'application/mbox; charset=UTF-8';
 		$fn .= '.mbox';
 	} else {
-		push @hdr, 'text/plain';
+		push @hdr, 'text/plain; charset=UTF-8';
 		$fn .= '.txt';
 	}
 	push @hdr, 'Content-Disposition', "inline; filename=$fn";
-- 
2.33.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] mbox: Specify encoding for raw message display
  2021-10-24 21:43   ` [PATCH 3/3] mbox: Specify encoding for raw message display Thomas Weißschuh
@ 2021-10-25  0:08     ` Eric Wong
  2021-10-25  5:42       ` Thomas Weißschuh
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2021-10-25  0:08 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: meta

Thomas Weißschuh <thomas@t-8ch.de> wrote:
> +++ b/lib/PublicInbox/Mbox.pm
> @@ -58,10 +58,10 @@ sub res_hdr ($$) {
>  	my @hdr = ('Content-Type');
>  	if ($ctx->{ibx}->{obfuscate}) {
>  		# obfuscation is stupid, but maybe scrapers are, too...
> -		push @hdr, 'application/mbox';
> +		push @hdr, 'application/mbox; charset=UTF-8';
>  		$fn .= '.mbox';
>  	} else {
> -		push @hdr, 'text/plain';
> +		push @hdr, 'text/plain; charset=UTF-8';
>  		$fn .= '.txt';

Applied and pushed patches 1 + 2, thanks.  This (3/3) seems
incorrect for non-UTF-8-compatible messages.

I should have a better approach for this in the next day or so.
The correct approach would be to use the Content-Type from the
$eml object, but the $eml object isn't likely in memory when
res_hdr() is called.

I was actually doing some surgery with the WwwStream /
GzipFilter async response components earlier, soI'll probably
get reading charset supported, soon.

Thanks for bringing this up.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] mbox: Specify encoding for raw message display
  2021-10-25  0:08     ` Eric Wong
@ 2021-10-25  5:42       ` Thomas Weißschuh
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2021-10-25  5:42 UTC (permalink / raw)
  To: Eric Wong; +Cc: meta

Hi Eric,

On 2021-10-25 00:08+0000, Eric Wong wrote:
> Date: Mon, 25 Oct 2021 00:08:24 +0000
> From: Eric Wong <e@80x24.org>
> To: Thomas Weißschuh <thomas@t-8ch.de>
> Cc: meta@public-inbox.org
> Subject: Re: [PATCH 3/3] mbox: Specify encoding for raw message display
> 
> Thomas Weißschuh <thomas@t-8ch.de> wrote:
> > +++ b/lib/PublicInbox/Mbox.pm
> > @@ -58,10 +58,10 @@ sub res_hdr ($$) {
> >  	my @hdr = ('Content-Type');
> >  	if ($ctx->{ibx}->{obfuscate}) {
> >  		# obfuscation is stupid, but maybe scrapers are, too...
> > -		push @hdr, 'application/mbox';
> > +		push @hdr, 'application/mbox; charset=UTF-8';
> >  		$fn .= '.mbox';
> >  	} else {
> > -		push @hdr, 'text/plain';
> > +		push @hdr, 'text/plain; charset=UTF-8';
> >  		$fn .= '.txt';
> 
> Applied and pushed patches 1 + 2, thanks.  This (3/3) seems
> incorrect for non-UTF-8-compatible messages.

Thanks.

> I should have a better approach for this in the next day or so.
> The correct approach would be to use the Content-Type from the
> $eml object, but the $eml object isn't likely in memory when
> res_hdr() is called.
> 
> I was actually doing some surgery with the WwwStream /
> GzipFilter async response components earlier, soI'll probably
> get reading charset supported, soon.

I'll take a look at it.

> Thanks for bringing this up.

Thanks for taking care.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-25  5:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-24 21:43 [PATCH 1/3] t/watch_maildir: support non-master default branch Thomas Weißschuh
2021-10-24 21:43 ` [PATCH 2/3] t/git: " Thomas Weißschuh
2021-10-24 21:43   ` [PATCH 3/3] mbox: Specify encoding for raw message display Thomas Weißschuh
2021-10-25  0:08     ` Eric Wong
2021-10-25  5:42       ` Thomas Weißschuh

Code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).