toptensoftware / markdowndeep

Open-source implementation of Markdown for C# and Javascript
268 stars 120 forks source link

Transform() crashes on the piece of markdown #12

Closed nightroman closed 10 years ago

nightroman commented 12 years ago

The following minimized piece of markdown makes Transform() to crash if ExtraMode && !SafeMode:

Term

: Definition

***

# Heading

Here is a PowerShell script ready to demonstrate the problem (replace the hardcoded DLL path with the actual):

Add-Type -Path C:\BIN\MarkdownDeep.dll

$markdown = New-Object MarkdownDeep.Markdown
$markdown.ExtraMode = $true
$markdown.SafeMode = $false

$text = @'

Term

: Definition

***

# Heading

'@

$markdown.Transform($text)
nightroman commented 12 years ago

Exception information:

MethodInvocationException:
Exception calling "Transform" with "1" argument(s): "Unable to cast object of type 'System.Boolean' to type 'System.String'."
At C:\TEMP\MarkdownDeep\_120308_230831.text.ps1:20 char:1
+ $markdown.Transform($text)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~

InvalidCastException:
Unable to cast object of type 'System.Boolean' to type 'System.String'.

System.Management.Automation.MethodInvocationException: Exception calling "Transform" with "1" argument(s): "Unable to cast object of type 'System.Boolean' to type 'System.String'." ---> System.InvalidCastException: Unable to cast object of type 'System.Boolean' to type 'System.String'.
   at MarkdownDeep.Block.ResolveHeaderID(Markdown m) in C:\TEMP\MarkdownDeep\Block.cs:line 124
   at MarkdownDeep.Block.Render(Markdown m, StringBuilder b) in C:\TEMP\MarkdownDeep\Block.cs:line 168
   at MarkdownDeep.Markdown.Transform(String str, Dictionary`2& definitions) in C:\TEMP\MarkdownDeep\MardownDeep.cs:line 136
   at MarkdownDeep.Markdown.Transform(String str) in C:\TEMP\MarkdownDeep\MardownDeep.cs:line 64
bootstraponline commented 12 years ago

Seems like a .NET specific issue. The JS version doesn't crash.

toptensoftware commented 10 years ago

Fixed in latest master for C# and JS