Skip to content

Commit

Permalink
Bugfix: os.environ was not checked in parse_path.
Browse files Browse the repository at this point in the history
This broke search.
  • Loading branch information
alga committed Oct 26, 2015
1 parent 725eea7 commit 3943df4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/irclog2html/irclogserver.py
Expand Up @@ -62,7 +62,7 @@ def parse_path(environ):
path = environ.get('PATH_INFO', '/')
path = path[1:] # Remove the leading slash
channel = None
if environ.get('IRCLOG_CHAN_DIR'):
if environ.get('IRCLOG_CHAN_DIR', os.environ.get('IRCLOG_CHAN_DIR')):
if '/' in path:
channel, path = path.split('/', 1)
if channel == '..':
Expand Down
8 changes: 8 additions & 0 deletions src/irclog2html/tests/test_irclogserver.py
Expand Up @@ -235,6 +235,14 @@ def test_chan_os_environ(self, environ):
self.assertIn(b'IRC logs', response.body)
self.assertIn(b'<a href="%23chan/">#chan</a>', response.body)

@mock.patch("os.environ")
def test_chan_search_page(self, environ):
os.environ.get = {"IRCLOG_CHAN_DIR": self.tmpdir}.get
response = self.request(
'/#chan/search')
self.assertEqual(response.content_type, 'text/html; charset=UTF-8')
self.assertIn(b'<title>Search IRC logs</title>', response.body)


def test_suite():
return unittest.TestSuite([
Expand Down

0 comments on commit 3943df4

Please sign in to comment.