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

problem with markdown component when input is null or string.empty #976

Closed
andreaspipp opened this issue Dec 11, 2024 · 1 comment · Fixed by #979
Closed

problem with markdown component when input is null or string.empty #976

andreaspipp opened this issue Dec 11, 2024 · 1 comment · Fixed by #979
Labels
area-markdown bug Something isn't working
Milestone

Comments

@andreaspipp
Copy link

Describe the bug
If you use the markdown component and give as input a null value or an empty string the whole component won't work anymore because it throws an ArgumentOutOfException exception.

To Reproduce

  1. Go to the demo website of this component https://demos.blazorbootstrap.com/markdown#live-preview
  2. clear the complete text from the markdown textarea
  3. the preview won't render anymore if you type valid markdown in the textarea

OR
<Markdown style="max-height: 437px;overflow-y:auto;"> @string.Empty </Markdown>

Expected behavior
display an empty string if the input is null or an empty string

Screenshots
When debugging in VS 2022 the problem lies in the GetLines() function in Markdown.cs when list.Count = 0 and the function tries ao access an item at position -1.
image

Versions (please complete the following information):

  • .NET Version: .NET 9
  • BlazorBootstrap: 3.2.0
  • Blazor WebAssembly / Server: Blazor Server
  • Blazor Interactive Render Mode: Server

Sample code
Sample code to reproduce the issue.

GitHub repo
GitHub repo with minimal code to reproduce the issue.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version 131
@andreaspipp andreaspipp changed the title Problem with MarkdownComponent when Input is null or string.empty problem with markdown component when input is null or string.empty Dec 11, 2024
@gvreddy04
Copy link
Contributor

@andreaspipp Thank you for reporting this.

@gvreddy04 gvreddy04 added this to the 3.3.0 milestone Dec 12, 2024
@gvreddy04 gvreddy04 added the bug Something isn't working label Dec 12, 2024
@gvreddy04 gvreddy04 linked a pull request Dec 16, 2024 that will close this issue
gvreddy04 added a commit that referenced this issue Dec 16, 2024
* #976 - Markdown null reference issue fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-markdown bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants