fix(xhttp): don't append trailing slash to file-like paths#2915
fix(xhttp): don't append trailing slash to file-like paths#2915voltara13 wants to merge 1 commit into
Conversation
NormalizedPath kept forcing a trailing slash on every path, which breaks xhttp paths that point at a file (e.g. /foo.txt). Skip the trailing slash when the last path segment contains a dot. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
91a7076 to
147b5b8
Compare
|
The current behavior matches that of the official client, and we have no interest in making any changes before XTLS/Xray-core#6307 is merged upstream. |
|
The argument "matches the official client" doesn't hold here: the official client (Xray-core) has the same bug — XTLS/Xray-core#6307 is open precisely because GetNormalizedPath unconditionally appends a trailing slash, which is wrong when sessionID and seq are placed in query/cookie/header rather than in the path. |
|
The heuristic used in this PR (skip trailing slash when the last segment contains a dot) is a workaround, not the correct fix. The trailing slash exists for one reason only: to separate the configured base path from the appended sessionID/seq segments, so the server can slice them back off via The correct condition is: if sessionIDPlacement == "path" || seqPlacement == "path" {
// append trailing slash
}This is exactly what XTLS/Xray-core#6307 implements. If neither field goes into the path, the configured path must be sent verbatim — no slash appended, no matter what the path looks like. A dot-based heuristic fails for paths like |
|
It is pointless to spend time discussing implementation details with me; if you want to resolve your issue, please urge the upstream project to make the necessary changes. We will synchronize the updates as soon as they are merged upstream. |
Xray-core has merged the upstream fix: Could this PR be reopened and adjusted to match Xray’s behavior? The current PR uses a file-like path heuristic, while upstream now appends the trailing slash only when sessionID or seq are placed in the path. Maybe mihomo could use the same condition as Xray here: if c.GetNormalizedSessionPlacement() == PlacementPath ||
c.GetNormalizedSeqPlacement() == PlacementPath {
if !strings.HasSuffix(path, "/") {
path += "/"
}
} |
Backport of the NormalizedPath fix onto v1.19.27. A trailing slash was forced onto every xhttp path, breaking paths that point at a file (e.g. /foo.txt). Skip the trailing slash when the last path segment contains a dot.