Skip to content

Double-check of FileInfo in SendFileFallback causes issues in templating #34575

Closed
@nibblesnbits

Description

@nibblesnbits

I've written a custom IFileProvider that does in-line replacements of file contents based on the incoming request. This worked back in .NET Core 2.2, but has since broken due to #12328.

The offending lines are below.

var fileInfo = new FileInfo(filePath);
if (offset < 0 || offset > fileInfo.Length)
{
throw new ArgumentOutOfRangeException(nameof(offset), offset, string.Empty);
}
if (count.HasValue &&
(count.Value < 0 || count.Value > fileInfo.Length - offset))
{
throw new ArgumentOutOfRangeException(nameof(count), count, string.Empty);
}

Is there a new suggested approach if I need to send a modified or different file from a custom IFileProvider? Also, is it stricly necessary to have this check at all?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.DocsThis issue tracks updating documentationStatus: Resolvedarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionshelp wantedUp for grabs. We would accept a PR to help resolve this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions