This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: netrc module not parsing passwords containing #s.
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ned.deily, r.david.murray, the_isz, xuanji
Priority: normal Keywords: patch

Created on 2010-11-20 09:28 by the_isz, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue_10464_fix.diff xuanji, 2010-11-25 15:12
Messages (8)
msg121598 - (view) Author: (the_isz) Date: 2010-11-20 09:28
The netrc module stops parsing passwords at # characters, which can be part of
passwords.

Tested with Python 2.7 and 3.1.
msg121623 - (view) Author: Xuanji Li (xuanji) * Date: 2010-11-20 12:37
Included test case for the reported bug. Test fails on my machine. Also split up test_case_1 (in order to put in the new test case cleanly)
msg121645 - (view) Author: Xuanji Li (xuanji) * Date: 2010-11-20 14:00
Sorry, patch had a mistake
msg121657 - (view) Author: Xuanji Li (xuanji) * Date: 2010-11-20 14:44
The issue seems to be that when shlex (the lexer that netrc uses) sees a '#' character it thinks that the rest of the line is a comment. I am not sure what the behavior of netrc should be - should it treat '#' as beginning a comment only if its the first non-whitespace character on a line? Should shlex be changed to reflect this?
msg122369 - (view) Author: Xuanji Li (xuanji) * Date: 2010-11-25 15:12
The patch attached (issue_10464_fix) moves handling of the '#' character from shlex to netrc, and makes netrc consider as comments lines whose first not-whitespace character is '#' instead of all text following '#' (which is what shlex does and which causes this bug). It also includes a test case.
msg122900 - (view) Author: Xuanji Li (xuanji) * Date: 2010-11-30 11:10
bumping...can someone review this? The reported bug seems valid enough.
msg122950 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2010-11-30 22:41
Patch looks good to me. Supplied test fails before and works after fix applied.
msg123048 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-02 03:17
Committed to py3k in r86925, 3.1 in r86926, and 2.7 in r86927.

Thanks for the patch, Xuanji.
History
Date User Action Args
2022-04-11 14:57:09adminsetgithub: 54673
2010-12-02 03:17:16r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg123048

resolution: fixed
stage: commit review -> resolved
2010-11-30 22:41:36ned.deilysetfiles: - issue_10231_testcase.diff
2010-11-30 22:41:24ned.deilysetnosy: + ned.deily

messages: + msg122950
stage: patch review -> commit review
2010-11-30 11:10:27xuanjisetmessages: + msg122900
2010-11-25 20:16:02ned.deilysetstage: patch review
versions: + Python 3.2
2010-11-25 15:12:01xuanjisetfiles: + issue_10464_fix.diff

messages: + msg122369
2010-11-20 14:44:47xuanjisetmessages: + msg121657
2010-11-20 14:00:01xuanjisetfiles: + issue_10231_testcase.diff

messages: + msg121645
2010-11-20 13:44:27xuanjisetfiles: - issue_10464_testcase.diff
2010-11-20 12:37:20xuanjisetfiles: + issue_10464_testcase.diff

nosy: + xuanji
messages: + msg121623

keywords: + patch
2010-11-20 09:28:37the_iszcreate