FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-99080: Preserve backslash character not used to escape quotes in .netrc files by stefanoboriero · Pull Request #99088 · python/cpython · GitHub

Repository navigation

gh-99080: Preserve backslash character not used to escape quotes in .netrc files - #99088

Open
stefanoboriero wants to merge 2 commits into
python:mainfrom
stefanoboriero:fix-issue-99080
Open

stefanoboriero wants to merge 2 commits into
python:mainfrom
stefanoboriero:fix-issue-99080

Conversation

stefanoboriero commented Nov 4, 2022 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown

Backslashes can be valid characters in password, they are not always used to escape symbols.
Treat backslash characters as escape symbols only for quotes in quotes when processing .netrc files.

Backslashes can be valid characters in password, they are not always
used to escape symbols.
Treat backslash characters as escape symbols only for quotes in quotes.

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

ghost commented Nov 4, 2022 •
edited by ghost
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

sveyret commented Dec 2, 2023

Copy link
Copy Markdown

Any news on this? The issue is getting spread on more and more computers and may stuck some people with a .netrc shared by multiple applications.

Copy link
Copy Markdown

Someone pointed me to: https://cgit.git.savannah.gnu.org/cgit/inetutils.git/tree/ftp/ruserpass.c#n362; the backslash is skipped there as well. This must have to do with the format of netrc files?

apteryks commented Jun 20, 2025 •
edited
Loading

Copy link
Copy Markdown

The current code matches what is done in GNU inetutils, and supposedly (chatgpt) GNU wget, Curl, and the other ftp implementations for parsing netrc files. Maybe the status quo is better, to preserve compatibility and behavior across tooling?

Copy link
Copy Markdown

As an extra data point, I checked what Emacs does and it differs from inetutlis: it doesn't do any unescaping (preserves everything literally), and only strip quotes at the edge of a netrc token:

(defun auth-source-netrc-looking-at-token ()
  "Say whether the next think in the buffer is a token (password, etc).
Match data is altered to reflect the token."
  (or (looking-at "'\\([^']*\\)'")
      (looking-at "\"\\([^\"]*\\)\"")
      (looking-at "\\([^ \t\n]+\\)")))

See: https://cgit.git.savannah.gnu.org/cgit/emacs.git/tree/lisp/auth-source.el#n1040

Copy link
Copy Markdown

Hi guys, what's the status here?

Curl does not have any issue treating my password's backslash as a backslash, instead of silently stripping it like the netrc python lib does. I spent two hours yesterday to find out why my python netrc test ran into a 401 authentication failure. Now I wrote my own code instead.

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL