Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,15 @@ public void ShouldSetSensitiveDataLoggingEnabled(bool value, bool expected)
[Arguments("'with;semi-colon'", "with;semi-colon")]
[Arguments("\"cn$r;'d^u_s4dm%^zr!frxqf\"", "cn$r;'d^u_s4dm%^zr!frxqf")]
[Arguments("{cn$r;'d^u_s4dm%^zr!frxqf}", "cn$r;'d^u_s4dm%^zr!frxqf")]
[Arguments("{UjX{N9n4e0p)Q.)_yhkKq", "{UjX{N9n4e0p)Q.)_yhkKq")]
[Arguments("'{UjX{N9n4e0p)Q.)_yhkKq'", "{UjX{N9n4e0p)Q.)_yhkKq")]
public void ShouldParseConnectionStringWithSpecialCharsInPassword(
string passwordInput,
string? expectedPassword
)
{
string connectionString =
$"Endpoint=http://127.0.0.1:8000;NS=test;DB=test;User=root;Password={passwordInput}";
$"Endpoint=http://127.0.0.1:8000;User=root;Password={passwordInput};NS=test;DB=test";

var options = new SurrealDbOptionsBuilder().FromConnectionString(connectionString).Build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ public SurrealDbOptionsBuilder FromConnectionString(string connectionString)
'{' => '}',
_ => throw new InvalidOperationException(),
};

// 💡 If no "final" char is matched in the next part of the string, then avoid doing it
isPossibleSurroundedPassword = span[(index + 1)..]
.Contains([expectedPasswordLastChar.Value], StringComparison.Ordinal);
if (!isPossibleSurroundedPassword)
{
expectedPasswordLastChar = null;
}
}

// 💡 Ignore if empty value
if (currentChar == ';')
{
currentPropertyValueEndIndex = index - 1;

TrySetProperty(ref span);
ResetForNextIteration();
}

index++;
Expand Down
Loading