Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105595
| From | Lele Gaifax <lele@metapensiero.it> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | netrc and password containing whitespace |
| Date | 2016-03-24 11:14 +0100 |
| Organization | Nautilus Entertainments |
| Message-ID | <mailman.85.1458814481.2244.python-list@python.org> (permalink) |
Hi all,
I tried to insert an entry in my ~/.netrc for an account having a password
that contains a space, something like:
machine my-host-name login myname password "My Password"
The standard library netrc module does not seem able to parse it, raising a
NetrcParseError. Other programs (Emacs, to mention one) do the right thing
with an entry like that.
Inspecting the module, I see that it explicitly put the quote chars (both
single and double, that is '"' and "'") in the shlex-based lexer's wordchars:
def _parse(self, file, fp, default_netrc):
lexer = shlex.shlex(fp)
lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
lexer.commenters = lexer.commenters.replace('#', '')
...
Since the method read_token() state machine gives higher priority to wordchars
over quotes, it obviously cannot parse the quoted string correctly:
...
elif self.posix and nextchar in self.escape:
escapedstate = 'a'
self.state = nextchar
elif nextchar in self.wordchars:
self.token = nextchar
self.state = 'a'
elif nextchar in self.quotes:
if not self.posix:
self.token = nextchar
self.state = nextchar
...
I was not able to lookup an exact definition of netrc's syntax, so I wonder:
is the implementation somewhat flawed, or am I missing something?
Thanks in advance for any hint,
ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele@metapensiero.it | -- Fortunato Depero, 1929.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
netrc and password containing whitespace Lele Gaifax <lele@metapensiero.it> - 2016-03-24 11:14 +0100
csiph-web