Skip to content

A (possible) bug in handling non-ASCII characters in the Location header #28624

Description

@aliostad

This snippet prints 404 in .NET Core while 200 in .NET Framework:

var url = "https://www.ilna.ir/fa/tiny/news-724227";
var client = new HttpClient();
var result = client.GetAsync(url).Result;
Console.WriteLine(result.StatusCode);

Basically there is a 301 response which has non-ASCII characters in the location header and gets garbled in .NET Core.

All browsers, cURL and .NET Framework and python happily follow the redirect.


To provide more context, the Location header gets url-encoded as

https://www.ilna.ir/%C3%98%C2%A8%C3%98%C2%AE%C3%98%C2%B4-%D8%A7%D9%82%D8%AA%D8%B5%D8%A7%D8%AF%DB%8C-4/724227-%DA%A9%D9%86%D8%AA%D8%B1%D9%84-%D9%86%D9%88%D8%B3%D8%A7%D9%86%D8%A7%D8%AA-%D8%A7%D8%B1%D8%B2%DB%8C-%D9%85%D9%87%D9%85-%D8%AA%D8%B1-%D8%A7%D8%B2-%DA%A9%D8%A7%D9%87%D8%B4-%D9%86%D8%B1%D8%AE-%D8%A7%D8%B1%D8%B2-%D8%A7%D8%B3%D8%AA-%D8%A8%D8%B1%D8%A7%DB%8C-%DA%A9%D8%A7%D8%B1%D8%A2%D9%81%D8%B1%DB%8C%D9%86%D8%A7%D9%86-%D9%81%D8%B1%D8%B4-%D9%82%D8%B1%D9%85%D8%B2-%D9%BE%D9%87%D9%86-%DA%A9%D8%B1%D8%AF%D9%87-%D8%A7%DB%8C%D9%85

Instead of

https://www.ilna.ir/%D8%A8%D8%AE%D8%B4-%D8%A7%D9%82%D8%AA%D8%B5%D8%A7%D8%AF%DB%8C-4/724227-%DA%A9%D9%86%D8%AA%D8%B1%D9%84-%D9%86%D9%88%D8%B3%D8%A7%D9%86%D8%A7%D8%AA-%D8%A7%D8%B1%D8%B2%DB%8C-%D9%85%D9%87%D9%85-%D8%AA%D8%B1-%D8%A7%D8%B2-%DA%A9%D8%A7%D9%87%D8%B4-%D9%86%D8%B1%D8%AE-%D8%A7%D8%B1%D8%B2-%D8%A7%D8%B3%D8%AA-%D8%A8%D8%B1%D8%A7%DB%8C-%DA%A9%D8%A7%D8%B1%D8%A2%D9%81%D8%B1%DB%8C%D9%86%D8%A7%D9%86-%D9%81%D8%B1%D8%B4-%D9%82%D8%B1%D9%85%D8%B2-%D9%BE%D9%87%D9%86-%DA%A9%D8%B1%D8%AF%D9%87-%D8%A7%DB%8C%D9%85

Note the difference of %C3%98%C2%A8%C3%98%C2%AE%C3%98%C2%B4 (wrong) vs %D8%A8%D8%AE%D8%B4 (correct).

Metadata

Metadata

Assignees

Labels

bugtenet-compatibilityIncompatibility with previous versions or .NET Framework

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions