Re: BUG #18735: Specific multibyte character in psql file path command parameter for Windows
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tatsuo Ishii <ishii@postgresql.org>
Cc: koichi.dbms@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2024-12-06T20:14:37Z
Lists: pgsql-bugs
I wrote: > Anyway, what I'm now thinking is that we can have two variants > of canonicalize_path: > extern void canonicalize_path(char *path); > extern void canonicalize_path_enc(char *path, int encoding); > The first one assumes a server-safe encoding, the second doesn't, > and at least to start with only psql would bother with the second. I thought that part would be trivial, but there's a small annoying problem. The obvious way to write the encoding-aware version of the de-backslashing loop is to use pg_encoding_mblen_bounded(). However, that function is in src/common/wchar.c while path.c is in src/port/ --- and I believe we have a rule that libpgport can't depend on libpgcommon. (The dependencies go the other way, instead.) Now it's pretty dubious that path.c is in src/port/ at all, because it does not meet the expectation that that directory is for functions that replace missing system-library functionality. (We've trodden pretty hard on that expectation over the years, but whatever.) So one reasonable fix could be to move path.c to src/common, but I'm concerned that that would be unsafe to back-patch. Also, we'd really want to move the externs for path.c out of port.h, which would cause additional code churn for callers. Another way, given that we only really need this to work for SJIS, is to hard-wire the logic into path.c --- it's not like pg_sjis_mblen is either long or likely to change. That's ugly but would be a lot less invasive and safer to back-patch. I'm leaning a bit to the second way, mainly because of the extern-relocation annoyance. regards, tom lane
Commits
-
Avoid breaking SJIS encoding while de-backslashing Windows paths.
- b17e3970c1ac 15.11 landed
- 998c4fc7c2c8 16.7 landed
- 98df8bace8a3 13.19 landed
- 6cddecdfb00b 18.0 landed
- 54f9afea7a7d 14.16 landed
- 0b713b94b3b0 17.3 landed