-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
Fix null reference when markdown content is empty #7463
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,14 +16,16 @@ internal class LinkInlineRenderer : VT100ObjectRenderer<LinkInline> | |
{ | ||
protected override void Write(VT100Renderer renderer, LinkInline obj) | ||
{ | ||
string text = obj?.FirstChild?.ToString(); | ||
|
||
// Format link as image or link. | ||
if (obj.IsImage) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If string text = obj?.FirstChild?.ToString();
if (text == null)
{
return;
}
// Golden path code... ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We allow text to be null hence the above logic holds. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @iSazonov |
||
{ | ||
renderer.Write(renderer.EscapeSequences.FormatImage(obj.FirstChild?.ToString())); | ||
renderer.Write(renderer.EscapeSequences.FormatImage(text)); | ||
} | ||
else | ||
{ | ||
renderer.Write(renderer.EscapeSequences.FormatLink(obj.FirstChild?.ToString(), obj.Url)); | ||
renderer.Write(renderer.EscapeSequences.FormatLink(text, obj.Url)); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string
instead ofvar
would be more obvious hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed