view tests/test-wsgicgi.t @ 50937:04bfcb416745 stable

hgweb: pass strings in WSGI environment correctly from wsgicgi According to PEP 3333, the strings in the WSGI environment must be translatable to bytes using the ISO-8859-1 codec.
author Manuel Jacob <me@manueljacob.de>
date Fri, 08 Sep 2023 15:33:03 +0200
parents
children
line wrap: on
line source

  $ hg init test
  $ cat >hgweb.cgi <<HGWEB
  > #!$PYTHON
  > from mercurial import demandimport; demandimport.enable()
  > from mercurial.hgweb import hgweb
  > from mercurial.hgweb import wsgicgi
  > application = hgweb(b"test", b"Empty test repository")
  > wsgicgi.launch(application)
  > HGWEB
  $ chmod 755 hgweb.cgi

Check that non-ASCII bytes roundtrip correctly.

  $ . "$TESTDIR/cgienv"
  $ PATH_INFO="/rev/$(python -c 'import sys; sys.stdout.buffer.write(b"\xe2\x80\x94")')"; export PATH_INFO
  $ QUERY_STRING="style=raw"; export QUERY_STRING
  $ "$PYTHON" ./hgweb.cgi | grep error
  error: unknown revision '\xe2\x80\x94' (esc)