Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix improperly parsed remark section #2935

Merged
merged 1 commit into from
Aug 20, 2020
Merged
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
3 changes: 2 additions & 1 deletion shadowsocks-csharp/Model/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ public static Server ParseURL(string serverUrl)
}
Server server = new Server
{
remarks = parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped),
remarks = HttpUtility.UrlDecode(parsedUrl.GetComponents(
UriComponents.Fragment, UriFormat.Unescaped), Encoding.UTF8),
server = parsedUrl.IdnHost,
server_port = parsedUrl.Port,
};
Expand Down
28 changes: 14 additions & 14 deletions test/UrlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ public void PrepareTestData()
server_port = server1.server_port,
password = server1.password,
method = server1.method,
remarks = "example-server"
remarks = "example-server 1"
};
server1WithRemarkCanonUrl = "ss://YmYtY2ZiOnRlc3RAMTkyLjE2OC4xMDAuMTo4ODg4#example-server";
server1WithRemarkCanonUrl = "ss://YmYtY2ZiOnRlc3RAMTkyLjE2OC4xMDAuMTo4ODg4#example-server+1";

server2WithRemark = new Server
{
server = server2.server,
server_port = server2.server_port,
password = server2.password,
method = server2.method,
remarks = "example-server"
remarks = "example-server 2"
};

server2WithRemarkCanonUrl = "ss://YmYtY2ZiOnRlc3RAMTkyLjE2OC4xLjE6ODM4OA==#example-server";
server2WithRemarkCanonUrl = "ss://YmYtY2ZiOnRlc3RAMTkyLjE2OC4xLjE6ODM4OA==#example-server+2";

server1WithPlugin = new Server
{
Expand Down Expand Up @@ -96,7 +96,7 @@ public void PrepareTestData()
remarks = server1WithRemark.remarks
};
server1WithPluginAndRemarkCanonUrl =
"ss://[email protected]:8888/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com#example-server";
"ss://[email protected]:8888/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com#example-server+1";

server2WithPluginAndRemark = new Server
{
Expand All @@ -109,7 +109,7 @@ public void PrepareTestData()
remarks = server2WithRemark.remarks
};
server2WithPluginAndRemarkCanonUrl =
"ss://[email protected]:8388/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com#example-server";
"ss://[email protected]:8388/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com#example-server+2";
}

[TestMethod]
Expand All @@ -122,7 +122,7 @@ public void TestParseUrl_Server1()
"\r\n",
"ss://YmYtY2ZiOnRlc3RAMTkyLjE2OC4xMDAuMTo4ODg4/",
server1WithRemarkCanonUrl,
"ss://YmYtY2ZiOnRlc3RAMTkyLjE2OC4xMDAuMTo4ODg4/#example-server"),
"ss://YmYtY2ZiOnRlc3RAMTkyLjE2OC4xMDAuMTo4ODg4/#example-server+1"),
new[]
{
server1,
Expand All @@ -137,11 +137,11 @@ public void TestParseUrl_Server1()
"ss://[email protected]:8888",
"\r\n",
"ss://[email protected]:8888/",
"ss://[email protected]:8888#example-server",
"ss://[email protected]:8888/#example-server",
"ss://[email protected]:8888#example-server+1",
"ss://[email protected]:8888/#example-server+1",
server1WithPluginCanonUrl,
server1WithPluginAndRemarkCanonUrl,
"ss://[email protected]:8888/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com&unsupported=1#example-server"),
"ss://[email protected]:8888/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com&unsupported=1#example-server+1"),
new[]
{
server1,
Expand All @@ -166,7 +166,7 @@ public void TestParseUrl_Server2()
"\r\n",
"ss://YmYtY2ZiOnRlc3RAMTkyLjE2OC4xLjE6ODM4OA==/",
server2WithRemarkCanonUrl,
"ss://YmYtY2ZiOnRlc3RAMTkyLjE2OC4xLjE6ODM4OA==/#example-server"),
"ss://YmYtY2ZiOnRlc3RAMTkyLjE2OC4xLjE6ODM4OA==/#example-server+2"),
new[]
{
server2,
Expand All @@ -181,11 +181,11 @@ public void TestParseUrl_Server2()
"ss://[email protected]:8388",
"\r\n",
"ss://[email protected]:8388/",
"ss://[email protected]:8388#example-server",
"ss://[email protected]:8388/#example-server",
"ss://[email protected]:8388#example-server+2",
"ss://[email protected]:8388/#example-server+2",
server2WithPluginCanonUrl,
server2WithPluginAndRemarkCanonUrl,
"ss://[email protected]:8388/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com&unsupported=1#example-server"),
"ss://[email protected]:8388/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com&unsupported=1#example-server+2"),
new[]
{
server2,
Expand Down