Skip to content

bug(CherryMarkdown): add max allow size parameter on Upload method#760

Merged
ArgoZhang merged 4 commits intomasterfrom
fix-markdown
Dec 1, 2025
Merged

bug(CherryMarkdown): add max allow size parameter on Upload method#760
ArgoZhang merged 4 commits intomasterfrom
fix-markdown

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Dec 1, 2025

Link issues

fixes #759

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Bug Fixes:

  • Prevent potential over-read or unrestricted read when opening the upload stream by passing the stream length to OpenReadStreamAsync.

Copilot AI review requested due to automatic review settings December 1, 2025 03:05
@bb-auto bb-auto Bot added the bug Something isn't working label Dec 1, 2025
@bb-auto bb-auto Bot added this to the v9.2.0 milestone Dec 1, 2025
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Dec 1, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

CherryMarkdown's Upload method is updated to pass a maximum allowed size to the JS stream's OpenReadStreamAsync call, and the component's copyright header is updated.

Sequence diagram for CherryMarkdown Upload max size handling

sequenceDiagram
    participant UserComponent
    participant CherryMarkdown
    participant JSRuntime
    participant IJSStreamReference
    participant OnFileUploadHandler

    UserComponent->>CherryMarkdown: Upload(uploadFile)
    activate CherryMarkdown

    CherryMarkdown->>JSRuntime: InvokeAsync IJSStreamReference("fetch", Id)
    JSRuntime-->>CherryMarkdown: IJSStreamReference stream

    alt stream not null
        CherryMarkdown->>IJSStreamReference: OpenReadStreamAsync(stream.Length)
        IJSStreamReference-->>CherryMarkdown: Stream data

        CherryMarkdown->>CherryMarkdown: uploadFile.UploadStream = data

        alt OnFileUpload handler exists
            CherryMarkdown->>OnFileUploadHandler: Invoke(uploadFile)
            OnFileUploadHandler-->>CherryMarkdown: Task completed
        end

        CherryMarkdown-->>UserComponent: string uploadResult
    else stream is null
        CherryMarkdown-->>UserComponent: string empty or error
    end

    deactivate CherryMarkdown
Loading

Class diagram for updated CherryMarkdown Upload method

classDiagram
    class CherryMarkdownUploadFile {
        Stream UploadStream
    }

    class CherryMarkdown {
        string Id
        Func~CherryMarkdownUploadFile, Task~ OnFileUpload
        Task~string~ Upload(CherryMarkdownUploadFile uploadFile)
    }

    class JSRuntime {
        Task~IJSStreamReference~ InvokeAsyncIJSStreamReference(string identifier, string id)
    }

    class IJSStreamReference {
        long Length
        Task~Stream~ OpenReadStreamAsync(long maxAllowedSize)
    }

    CherryMarkdown --> CherryMarkdownUploadFile : uses
    CherryMarkdown --> JSRuntime : calls
    CherryMarkdown --> IJSStreamReference : uses
    CherryMarkdownUploadFile --> IJSStreamReference : holds
    IJSStreamReference <|.. JSRuntime : returned by
Loading

File-Level Changes

Change Details Files
Limit the JS stream read in CherryMarkdown.Upload by passing a maximum allowed size to OpenReadStreamAsync.
  • Change Upload to call OpenReadStreamAsync with the stream length as a max-allowed-size argument before assigning UploadStream.
  • Preserve existing upload callback flow, only constraining the stream reading behavior.
src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs
Update library copyright header metadata.
  • Adjust CherryMarkdown component copyright notice to attribute both BootstrapBlazor and Argo Zhang with a new email address.
src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs
src/components/BootstrapBlazor.CherryMarkdown/BootstrapBlazor.CherryMarkdown.csproj

Assessment against linked issues

Issue Objective Addressed Explanation
#759 Add and use a maximum allowed size parameter when opening the upload stream in CherryMarkdown.Upload to avoid default size limitations/errors.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ArgoZhang ArgoZhang merged commit 0adc214 into master Dec 1, 2025
5 of 6 checks passed
@ArgoZhang ArgoZhang deleted the fix-markdown branch December 1, 2025 03:05
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #759 by fixing a bug in the CherryMarkdown component's file upload functionality. The default maximum size for OpenReadStreamAsync is only 512KB, which causes exceptions when uploading larger files. The fix passes stream.Length as the maxAllowedSize parameter to allow files of any size to be uploaded.

  • Added stream.Length parameter to OpenReadStreamAsync call to support larger file uploads
  • Updated copyright header to align with newer codebase convention
  • Bumped version to 10.0.1

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
CherryMarkdown.razor.cs Fixed file upload size limitation by passing stream.Length to OpenReadStreamAsync; updated copyright header
BootstrapBlazor.CherryMarkdown.csproj Added version property set to 10.0.1

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(CherryMarkdown): add max allow size parameter on Upload method

2 participants