Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105595

netrc and password containing whitespace

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Lele Gaifax <lele@metapensiero.it>
Newsgroups comp.lang.python
Subject netrc and password containing whitespace
Date Thu, 24 Mar 2016 11:14:31 +0100
Organization Nautilus Entertainments
Lines 46
Message-ID <mailman.85.1458814481.2244.python-list@python.org> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de VAVQccU21JR6kDdklApF1wXa6Mxpvql+MoWz56WYNZPw==
Cancel-Lock sha1:Z6Nkv/l5plxejaQw4J3KfvsWod0=
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'elif': 0.04; 'subject:password': 0.05; "'')": 0.07; "'a'": 0.07; '"my': 0.09; 'lookup': 0.09; 'received:151': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'advance': 0.10; 'def': 0.13; 'explicitly': 0.15; 'file,': 0.15; '\'"\'': 0.16; '_parse(self,': 0.16; 'email addr:[\\]^_`{|}~"""': 0.16; 'email name:r"""!"#$%&\'()*+,-./:;?': 0.16; 'lexer': 0.16; 'nextchar': 0.16; 'one)': 0.16; 'quoted': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'obviously': 0.16; 'string': 0.17; 'module,': 0.18; 'all,': 0.20; 'library': 0.20; 'machine': 0.21; 'parse': 0.22; 'insert': 0.23; 'tried': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'that.': 0.30; 'mention': 0.30; 'entry': 0.31; 'raising': 0.33; 'definition': 0.34; 'gives': 0.35; 'something': 0.35; 'to:addr:python-list': 0.36; 'method': 0.37; 'thanks': 0.37; 'received:org': 0.37; 'missing': 0.37; 'seem': 0.37; 'does': 0.39; 'to:addr:python.org': 0.40; 'programs': 0.62; 'skip:n 10': 0.62; 'aver': 0.66; 'account': 0.66; 'che': 0.67; 'quello': 0.84; 'quando': 0.91
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host 151.62.77.221
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:105595

Show key headers only | View raw


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


Thread

netrc and password containing whitespace Lele Gaifax <lele@metapensiero.it> - 2016-03-24 11:14 +0100

csiph-web