Description
Is it reproducible with SwiftPM command-line tools: swift build
, swift test
, swift package
etc?
- Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands,
swift build
,swift test
,swift package
etc.
Description
if i use a sample .netrc file as below:
machine blah.com
login test_user
password first#second
the # symbol in the password causes it to be not read entirely, it gets processed as just 'first', with the remaining characters "second" treated as a comment.
I believe this comes from this function
I understand comments need to be handled, but i think I would expect that if the password is all one 'word', i.e. no spaces, that it should still be treated as part of the password
Expected behavior
Values in .netrc containing hash symbols are processed as they are, including hash symbols, i.e. in the above example, the password value of "first#second" is used
Actual behavior
Value are truncated at the point of the location of the hash symbol due to the following characters being treated as comments, i.e. in the above example, the password value of "first" is used
Steps to reproduce
Have a .netrc file containing the following:
machine blah.com
login test_user
password first#second
Capture "Authorisation" header used in request from SPM to fetch binary target
Notice that it has the password truncated, so be "first", and does not include the entire value "first#second"
Sample unit test added to NetrcTests.swift
to reproduce it :
func testHashSymbolInPassword() throws {
let content = """
machine example.com
login anonymous
password qw#erty
"""
let netrc = try NetrcParser.parse(content)
let machine = netrc.machines.first
XCTAssertEqual(machine?.name, "example.com")
XCTAssertEqual(machine?.login, "anonymous")
XCTAssertEqual(machine?.password, "qw#erty")
}
See output below:

Swift Package Manager version/commit hash
main (0b569a1)
Swift & OS version (output of swift --version ; uname -a
)
swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx15.0
Darwin mb-garyo 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:39:07 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6000 arm64