Description
On systems with repository roots whose directory names contain non-ASCII
characters (say, for example, a UTF-8 Japanese string), ViewVC will fail to
correctly convert the path into UTF-8 as required by Subversion's API.
Metadata Imported from Tigris (Issue 500)
- Creation Date: 2011-11-14 11:13:31
- Reporter: cmpilato
- Subcomponent: core
- Version: 1.1.12
- Milestone: unscheduled
- Keywords: patch
- Cc:
Comments
2011-11-14 11:16:25 by cmpilato
Created an attachment (id=256)
Not-fully-tested patch for this issue
2011-11-14 14:06:59 by cmpilato
Created an attachment (id=257)
Not-fully-tested patch for this issue (v2)
2011-11-28 08:49:03 by cmpilato
This would be less tedious, I think, if 'viewvc-install' (which is less likely
to be running in a "C"-locale shell) would query the system's locale and
populate the appropriate configuration bits.
Attachments
issue-500-patch.txt - Not-fully-tested patch for this issue
Posted 2011-11-14 11:16:25 by cmpilato
Fix issue #500 ("ViewVC chokes on non-ASCII Subversion repository root
name").
* conf/viewvc.conf.dist
(general.locale): New.
* lib/config.py
(Config.set_defaults): Set default value for general.locale (to None).
* bin/asp/query.asp,
* bin/asp/viewvc.asp,
* bin/cgi/query.cgi,
* bin/cgi/viewvc.cgi,
* bin/cvsdbadmin,
* bin/loginfo-handler,
* bin/mod_python/query.py,
* bin/mod_python/viewvc.py,
* bin/standalone.py,
* bin/svndbadmin,
* bin/wsgi/query.wsgi,
* bin/wsgi/viewvc.fcgi,
* bin/wsgi/viewvc.wsgi
After fetching the Config object, call locale.setlocale() to dictate
any configured locale.
--This line, and those below, will be ignored--
Index: conf/viewvc.conf.dist
===================================================================
--- conf/viewvc.conf.dist (revision 2670)
+++ conf/viewvc.conf.dist (working copy)
@@ -197,6 +197,17 @@
##
#address =
+## locale: Specifies the server's system locale. This helps ViewVC
+## know how to interact with your server, for example when it needs to
+## convert between its internal path encoding and the encoding used on
+## your system.
+##
+## Examples:
+## locale = en_US.UTF-8
+## locale = Russian_Russia.1251
+##
+#locale =
+
## kv_files: Provides a mechanism for custom key/value pairs to be
## available to templates. These are stored in key/value (KV) files.
##
Index: lib/config.py
===================================================================
--- lib/config.py (revision 2670)
+++ lib/config.py (working copy)
@@ -382,6 +382,7 @@
self.general.address = ''
self.general.kv_files = [ ]
self.general.languages = ['en-us']
+ self.general.locale = None
self.utilities.rcs_dir = ''
if sys.platform == "win32":
Index: bin/standalone.py
===================================================================
--- bin/standalone.py (revision 2670)
+++ bin/standalone.py (working copy)
@@ -422,6 +422,9 @@
def handle_config(config_file):
global cfg
cfg = viewvc.load_config(config_file or CONF_PATHNAME)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
def usage():
Index: bin/mod_python/viewvc.py
===================================================================
--- bin/mod_python/viewvc.py (revision 2670)
+++ bin/mod_python/viewvc.py (working copy)
@@ -55,6 +55,9 @@
def index(req):
server = sapi.ModPythonServer(req)
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
try:
viewvc.main(server, cfg)
finally:
Index: bin/mod_python/query.py
===================================================================
--- bin/mod_python/query.py (revision 2670)
+++ bin/mod_python/query.py (working copy)
@@ -61,6 +61,9 @@
fp.close()
cfg = viewvc.load_config(CONF_PATHNAME)
+if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
def index(req):
server = sapi.ModPythonServer(req)
Index: bin/asp/viewvc.asp
===================================================================
--- bin/asp/viewvc.asp (revision 2670)
+++ bin/asp/viewvc.asp (working copy)
@@ -58,6 +58,9 @@
server = sapi.AspServer(Server, Request, Response, Application)
try:
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc.main(server, cfg)
finally:
s.close()
Index: bin/asp/query.asp
===================================================================
--- bin/asp/query.asp (revision 2670)
+++ bin/asp/query.asp (working copy)
@@ -54,6 +54,9 @@
server = sapi.AspServer(Server, Request, Response, Application)
try:
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc_base_url = cfg.query.viewvc_base_url
if viewvc_base_url is None:
viewvc_base_url = "viewvc.asp"
Index: bin/svndbadmin
===================================================================
--- bin/svndbadmin (revision 2670)
+++ bin/svndbadmin (working copy)
@@ -239,6 +239,9 @@
def main(command, repository, revs=[], verbose=0, force=0):
cfg = viewvc.load_config(CONF_PATHNAME)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
db = cvsdb.ConnectDatabase(cfg)
# Purge what must be purged.
Index: bin/cgi/viewvc.cgi
===================================================================
--- bin/cgi/viewvc.cgi (revision 2670)
+++ bin/cgi/viewvc.cgi (working copy)
@@ -58,4 +58,7 @@
server = sapi.CgiServer()
cfg = viewvc.load_config(CONF_PATHNAME, server)
+if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc.main(server, cfg)
Index: bin/cgi/query.cgi
===================================================================
--- bin/cgi/query.cgi (revision 2670)
+++ bin/cgi/query.cgi (working copy)
@@ -54,6 +54,9 @@
server = sapi.CgiServer()
cfg = viewvc.load_config(CONF_PATHNAME, server)
+if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc_base_url = cfg.query.viewvc_base_url
if viewvc_base_url is None:
viewvc_base_url = "viewvc.cgi"
Index: bin/loginfo-handler
===================================================================
--- bin/loginfo-handler (revision 2670)
+++ bin/loginfo-handler (working copy)
@@ -221,6 +221,9 @@
def ProcessLoginfo(rootpath, directory, files):
cfg = viewvc.load_config(CONF_PATHNAME)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
db = cvsdb.ConnectDatabase(cfg)
repository = vclib.ccvs.CVSRepository(None, rootpath, None,
cfg.utilities, 0)
Index: bin/wsgi/viewvc.fcgi
===================================================================
--- bin/wsgi/viewvc.fcgi (revision 2670)
+++ bin/wsgi/viewvc.fcgi (working copy)
@@ -44,6 +44,9 @@
def application(environ, start_response):
server = sapi.WsgiServer(environ, start_response)
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc.main(server, cfg)
return []
Index: bin/wsgi/viewvc.wsgi
===================================================================
--- bin/wsgi/viewvc.wsgi (revision 2670)
+++ bin/wsgi/viewvc.wsgi (working copy)
@@ -37,5 +37,8 @@
def application(environ, start_response):
server = sapi.WsgiServer(environ, start_response)
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc.main(server, cfg)
return []
Index: bin/wsgi/query.wsgi
===================================================================
--- bin/wsgi/query.wsgi (revision 2670)
+++ bin/wsgi/query.wsgi (working copy)
@@ -38,6 +38,9 @@
def application(environ, start_response):
server = sapi.WsgiServer(environ, start_response)
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc_base_url = cfg.query.viewvc_base_url
if viewvc_base_url is None:
viewvc_base_url = "viewvc.wsgi"
Index: bin/cvsdbadmin
===================================================================
--- bin/cvsdbadmin (revision 2670)
+++ bin/cvsdbadmin (working copy)
@@ -171,6 +171,9 @@
rootpath = vclib.ccvs.canonicalize_rootpath(root)
try:
cfg = viewvc.load_config(CONF_PATHNAME)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
db = cvsdb.ConnectDatabase(cfg)
if command in ('rebuild', 'purge'):
issue-500-patch.2.txt - Not-fully-tested patch for this issue (v2)
Posted 2011-11-14 14:06:58 by cmpilato
Fix issue #500 ("ViewVC chokes on non-ASCII Subversion repository root
name").
* conf/viewvc.conf.dist
(general.locale): New.
* lib/config.py
(Config.set_defaults): Set default value for general.locale (to None).
* bin/asp/query.asp,
* bin/asp/viewvc.asp,
* bin/cgi/query.cgi,
* bin/cgi/viewvc.cgi,
* bin/cvsdbadmin,
* bin/loginfo-handler,
* bin/mod_python/query.py,
* bin/mod_python/viewvc.py,
* bin/standalone.py,
* bin/svndbadmin,
* bin/wsgi/query.wsgi,
* bin/wsgi/viewvc.fcgi,
* bin/wsgi/viewvc.wsgi
After fetching the Config object, call locale.setlocale() to dictate
any configured locale.
--This line, and those below, will be ignored--
Index: conf/viewvc.conf.dist
===================================================================
--- conf/viewvc.conf.dist (revision 2670)
+++ conf/viewvc.conf.dist (working copy)
@@ -197,6 +197,17 @@
##
#address =
+## locale: Specifies the server's system locale. This helps ViewVC
+## know how to interact with your server, for example when it needs to
+## convert between its internal path encoding and the encoding used on
+## your system.
+##
+## Examples:
+## locale = en_US.UTF-8
+## locale = Russian_Russia.1251
+##
+#locale =
+
## kv_files: Provides a mechanism for custom key/value pairs to be
## available to templates. These are stored in key/value (KV) files.
##
Index: lib/config.py
===================================================================
--- lib/config.py (revision 2670)
+++ lib/config.py (working copy)
@@ -382,6 +382,7 @@
self.general.address = ''
self.general.kv_files = [ ]
self.general.languages = ['en-us']
+ self.general.locale = None
self.utilities.rcs_dir = ''
if sys.platform == "win32":
Index: bin/standalone.py
===================================================================
--- bin/standalone.py (revision 2670)
+++ bin/standalone.py (working copy)
@@ -422,6 +422,9 @@
def handle_config(config_file):
global cfg
cfg = viewvc.load_config(config_file or CONF_PATHNAME)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
def usage():
Index: bin/mod_python/viewvc.py
===================================================================
--- bin/mod_python/viewvc.py (revision 2670)
+++ bin/mod_python/viewvc.py (working copy)
@@ -55,6 +55,9 @@
def index(req):
server = sapi.ModPythonServer(req)
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
try:
viewvc.main(server, cfg)
finally:
Index: bin/mod_python/query.py
===================================================================
--- bin/mod_python/query.py (revision 2670)
+++ bin/mod_python/query.py (working copy)
@@ -61,6 +61,9 @@
fp.close()
cfg = viewvc.load_config(CONF_PATHNAME)
+if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
def index(req):
server = sapi.ModPythonServer(req)
Index: bin/asp/viewvc.asp
===================================================================
--- bin/asp/viewvc.asp (revision 2670)
+++ bin/asp/viewvc.asp (working copy)
@@ -58,6 +58,9 @@
server = sapi.AspServer(Server, Request, Response, Application)
try:
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc.main(server, cfg)
finally:
s.close()
Index: bin/asp/query.asp
===================================================================
--- bin/asp/query.asp (revision 2670)
+++ bin/asp/query.asp (working copy)
@@ -54,6 +54,9 @@
server = sapi.AspServer(Server, Request, Response, Application)
try:
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc_base_url = cfg.query.viewvc_base_url
if viewvc_base_url is None:
viewvc_base_url = "viewvc.asp"
Index: bin/svndbadmin
===================================================================
--- bin/svndbadmin (revision 2670)
+++ bin/svndbadmin (working copy)
@@ -239,6 +239,9 @@
def main(command, repository, revs=[], verbose=0, force=0):
cfg = viewvc.load_config(CONF_PATHNAME)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
db = cvsdb.ConnectDatabase(cfg)
# Purge what must be purged.
Index: bin/cgi/viewvc.cgi
===================================================================
--- bin/cgi/viewvc.cgi (revision 2670)
+++ bin/cgi/viewvc.cgi (working copy)
@@ -58,4 +58,7 @@
server = sapi.CgiServer()
cfg = viewvc.load_config(CONF_PATHNAME, server)
+if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc.main(server, cfg)
Index: bin/cgi/query.cgi
===================================================================
--- bin/cgi/query.cgi (revision 2670)
+++ bin/cgi/query.cgi (working copy)
@@ -54,6 +54,9 @@
server = sapi.CgiServer()
cfg = viewvc.load_config(CONF_PATHNAME, server)
+if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc_base_url = cfg.query.viewvc_base_url
if viewvc_base_url is None:
viewvc_base_url = "viewvc.cgi"
Index: bin/loginfo-handler
===================================================================
--- bin/loginfo-handler (revision 2670)
+++ bin/loginfo-handler (working copy)
@@ -221,6 +221,9 @@
def ProcessLoginfo(rootpath, directory, files):
cfg = viewvc.load_config(CONF_PATHNAME)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
db = cvsdb.ConnectDatabase(cfg)
repository = vclib.ccvs.CVSRepository(None, rootpath, None,
cfg.utilities, 0)
Index: bin/wsgi/viewvc.fcgi
===================================================================
--- bin/wsgi/viewvc.fcgi (revision 2670)
+++ bin/wsgi/viewvc.fcgi (working copy)
@@ -44,6 +44,9 @@
def application(environ, start_response):
server = sapi.WsgiServer(environ, start_response)
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc.main(server, cfg)
return []
Index: bin/wsgi/query.fcgi
===================================================================
--- bin/wsgi/query.fcgi (revision 2670)
+++ bin/wsgi/query.fcgi (working copy)
@@ -45,6 +45,9 @@
def application(environ, start_response):
server = sapi.WsgiServer(environ, start_response)
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc_base_url = cfg.query.viewvc_base_url
if viewvc_base_url is None:
viewvc_base_url = "viewvc.fcgi"
Index: bin/wsgi/viewvc.wsgi
===================================================================
--- bin/wsgi/viewvc.wsgi (revision 2670)
+++ bin/wsgi/viewvc.wsgi (working copy)
@@ -37,5 +37,8 @@
def application(environ, start_response):
server = sapi.WsgiServer(environ, start_response)
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc.main(server, cfg)
return []
Index: bin/wsgi/query.wsgi
===================================================================
--- bin/wsgi/query.wsgi (revision 2670)
+++ bin/wsgi/query.wsgi (working copy)
@@ -38,6 +38,9 @@
def application(environ, start_response):
server = sapi.WsgiServer(environ, start_response)
cfg = viewvc.load_config(CONF_PATHNAME, server)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
viewvc_base_url = cfg.query.viewvc_base_url
if viewvc_base_url is None:
viewvc_base_url = "viewvc.wsgi"
Index: bin/cvsdbadmin
===================================================================
--- bin/cvsdbadmin (revision 2670)
+++ bin/cvsdbadmin (working copy)
@@ -171,6 +171,9 @@
rootpath = vclib.ccvs.canonicalize_rootpath(root)
try:
cfg = viewvc.load_config(CONF_PATHNAME)
+ if cfg.general.locale is not None:
+ import locale
+ locale.setlocale(locale.LC_ALL, cfg.general.locale)
db = cvsdb.ConnectDatabase(cfg)
if command in ('rebuild', 'purge'):
bug patch