unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#52792: 27.2; please don't hardcode utf-8 when fetching group list
@ 2021-12-25 16:19 LdBeth
  2021-12-26  2:00 ` LdBeth
  0 siblings, 1 reply; 5+ messages in thread
From: LdBeth @ 2021-12-25 16:19 UTC (permalink / raw)
  To: 52792


The problematic code is located at gnus-srvr.el,
`gnus-browse-foreign-server' in commit
cb12a84f2c519a48dd87453c925e3bc36d9944db, that hard codes
`utf-8-emacs' for group lists. That would cause problems for NNTP
servers that are still not using utf-8, which is common among some
Chinese servers that widely uses gbk coding. It would render group
subscription unusable when `gnus-group-name-charset-group-alist' has
been setup to translate the group names, because Gnus would think
the translated group names different from the wrongly decoded group name
fetched from the server.

I propose for reverting the removal of group name encoding, although I
didn't fully understand the reason for that commit. Or at least,
consider add a method to set the encoding for particular server, to
work around this problem.

-- 
LDB





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

* bug#52792: 27.2; please don't hardcode utf-8 when fetching group list
  2021-12-25 16:19 bug#52792: 27.2; please don't hardcode utf-8 when fetching group list LdBeth
@ 2021-12-26  2:00 ` LdBeth
  2021-12-26  2:25   ` LdBeth
  2021-12-26  7:00   ` Eli Zaretskii
  0 siblings, 2 replies; 5+ messages in thread
From: LdBeth @ 2021-12-26  2:00 UTC (permalink / raw)
  To: 52792

[-- Attachment #1: Type: text/plain, Size: 173 bytes --]


This patch that reverts only related changes (and does nothing else)
in cb12a84f2c519a48dd87453c925e3bc36d9944db should make Gnus works
again for none utf-8 NNTP servers.


[-- Attachment #2: revert.diff --]
[-- Type: text/plain, Size: 1263 bytes --]

--- gnus-srvr.el.old	2021-12-26 09:48:28.000000000 +0800
+++ gnus-srvr.el	2021-12-26 09:55:45.000000000 +0800
@@ -784,13 +784,11 @@
 	      (while (not (eobp))
 		(ignore-errors
 		  (push (cons
-			 (decode-coding-string
 			  (buffer-substring
 			   (point)
 			   (progn
 			     (skip-chars-forward "^ \t")
 			     (point)))
-			  'utf-8-emacs)
 			 (let ((last (read cur)))
 			   (cons (read cur) last)))
 			groups))
@@ -798,7 +796,6 @@
 	    (while (not (eobp))
 	      (ignore-errors
 		(push (cons
-		       (decode-coding-string
 			(if (eq (char-after) ?\")
 			    (read cur)
 			  (let ((p (point)) (name ""))
@@ -811,7 +808,6 @@
 			      (setq name (concat name (buffer-substring
 						       p (point)))))
 			    name))
-			'utf-8-emacs)
 		       (let ((last (read cur)))
 			 (cons (read cur) last)))
 		      groups))
@@ -863,7 +859,12 @@
 			   ((= level gnus-level-zombie) ?Z)
 			   (t ?K)))
 			(max 0 (- (1+ (cddr group)) (cadr group)))
-			name)))
+				;; Don't decode if name is ASCII
+			(if (eq (detect-coding-string name t) 'undecided)
+			    name
+			  (decode-coding-string
+			   name
+			   (inline (gnus-group-name-charset method name)))))))
 	     (list 'gnus-group name)
 	     )))
 	(switch-to-buffer (current-buffer)))

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

* bug#52792: 27.2; please don't hardcode utf-8 when fetching group list
  2021-12-26  2:00 ` LdBeth
@ 2021-12-26  2:25   ` LdBeth
  2021-12-26  7:00   ` Eli Zaretskii
  1 sibling, 0 replies; 5+ messages in thread
From: LdBeth @ 2021-12-26  2:25 UTC (permalink / raw)
  To: 52792

>>>>> In <tencent_03F53C61E4EB9C58CDFE99B951775739820A@qq.com> 
>>>>>	LdBeth <andpuke@foxmail.com> wrote:
ldb> [1  <text/plain; US-ASCII (7bit)>]

ldb> This patch that reverts only related changes (and does nothing
ldb> else) in cb12a84f2c519a48dd87453c925e3bc36d9944db should make
ldb> Gnus works again for none utf-8 NNTP servers.

ldb> [2 revert.diff <text/plain; US-ASCII (7bit)>]

Unfortunately that only resolves the display problem, to enable
correct subscription on none UTF-8 nntp server would require undone
other changes in cb12a84f2c519a48dd87453c925e3bc36d9944db.

-- 
LDB





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

* bug#52792: 27.2; please don't hardcode utf-8 when fetching group list
  2021-12-26  2:00 ` LdBeth
  2021-12-26  2:25   ` LdBeth
@ 2021-12-26  7:00   ` Eli Zaretskii
  2021-12-26  9:49     ` LdBeth
  1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2021-12-26  7:00 UTC (permalink / raw)
  To: LdBeth; +Cc: 52792

> Date: Sun, 26 Dec 2021 10:00:42 +0800
> From: LdBeth <andpuke@foxmail.com>
> 
> This patch that reverts only related changes (and does nothing else)
> in cb12a84f2c519a48dd87453c925e3bc36d9944db should make Gnus works
> again for none utf-8 NNTP servers.

Thanks, but this is not the right way to solve such problems, IMO.  We
should either make the coding-system be customizable as a simple
value, or (better) have a more complex data structure that allows to
specify the encoding for each NNTP server (or for servers matching
some regexp), with UTF-8 being the default.

Also, AFAICT, Gnus currently uses more than a single variable to hold
the coding-system it uses for decoding stuff in different situations,
so some changes will probably be needed to use a single customizable
value everywhere.





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

* bug#52792: 27.2; please don't hardcode utf-8 when fetching group list
  2021-12-26  7:00   ` Eli Zaretskii
@ 2021-12-26  9:49     ` LdBeth
  0 siblings, 0 replies; 5+ messages in thread
From: LdBeth @ 2021-12-26  9:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: LdBeth, 52792

>>>>> In <83tuevq28p.fsf@gnu.org> 
>>>>>	Eli Zaretskii <eliz@gnu.org> wrote:

> Thanks, but this is not the right way to solve such problems, IMO.  We
> should either make the coding-system be customizable as a simple
> value, or (better) have a more complex data structure that allows to
> specify the encoding for each NNTP server (or for servers matching
> some regexp), with UTF-8 being the default.

Right, it would be more desirable to use UTF-8 internally, rather than
doing ad-hoc encoding translation everywhere.

> Also, AFAICT, Gnus currently uses more than a single variable to hold
> the coding-system it uses for decoding stuff in different situations,
> so some changes will probably be needed to use a single customizable
> value everywhere.

Currently the encode/decode functions in message.el works fine for
GBK, this bug would not affect people who are only using Gnus for
IMAP/Maildir.  It would still better leaving these two systems (News
and Messages) separated. Today most email services are already
switched to UTF-8. It's only that many NNTP servers are still using
the old encoding for legacy reasons.

-- 
LDB





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

end of thread, other threads:[~2021-12-26  9:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-25 16:19 bug#52792: 27.2; please don't hardcode utf-8 when fetching group list LdBeth
2021-12-26  2:00 ` LdBeth
2021-12-26  2:25   ` LdBeth
2021-12-26  7:00   ` Eli Zaretskii
2021-12-26  9:49     ` LdBeth

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

	https://git.savannah.gnu.org/cgit/emacs.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).