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

Deleting HTML tags when newlines present causes a crash #159

Closed
cyotek opened this Issue Jun 26, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@cyotek

cyotek commented Jun 26, 2016

I was busy removing HTML tags from some content I'd pasted into MDE when MDE crashed and burned. I finally managed to pin it down to HTML content containing line breaks.

Paste the following into MDE, but remove the leading spaces to both lines that I've added to make it a code block in this ticket

<p>Some HTML with 
a line break</p>

Next, delete the starting <p> tag.

Now, stick your cursor at the end of the second line, and start pressing backspace to delete the </p> tag. As soon as the p> characters have been removed MDE explodes.

Here's the information from the Event Log, although I doubt you'd need it as it's readily reproducible

Application: mde.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IndexOutOfRangeException
   at CommonMark.Parser.Scanner.scan_autolink_uri(System.String, Int32, Int32)
   at CommonMark.Parser.InlineMethods.handle_pointy_brace(CommonMark.Parser.Subject)
   at CommonMark.Parser.InlineMethods.parse_inlines(CommonMark.Parser.Subject, System.Func`2<CommonMark.Parser.Subject,CommonMark.Syntax.Inline>[], Char[])
   at CommonMark.Parser.BlockMethods.ProcessInlines(CommonMark.Syntax.Block, CommonMark.Syntax.DocumentData, CommonMark.CommonMarkSettings)
   at CommonMark.CommonMarkConverter.ProcessStage2(CommonMark.Syntax.Block, CommonMark.CommonMarkSettings)

Exception Info: CommonMark.CommonMarkException
   at CommonMark.CommonMarkConverter.ProcessStage2(CommonMark.Syntax.Block, CommonMark.CommonMarkSettings)
   at MarkdownEdit.Models.Markdown.GenerateAbstractSyntaxTree(System.String)
   at MarkdownEdit.Controls.Editor+<>c__DisplayClass107_0.<SetupSyntaxHighlighting>b__0(System.Object, System.EventArgs)
   at System.EventHandler.Invoke(System.Object, System.EventArgs)
   at System.EventHandler.Invoke(System.Object, System.EventArgs)
   at ICSharpCode.AvalonEdit.TextEditor.OnTextChanged(System.EventArgs)
   at ICSharpCode.AvalonEdit.TextEditor.ReceiveWeakEvent(System.Type, System.Object, System.EventArgs)
   at System.Windows.WeakEventManager+ListenerList.DeliverEvent(Listener ByRef, System.Object, System.EventArgs, System.Type)
   at System.Windows.WeakEventManager+ListenerList.DeliverEvent(System.Object, System.EventArgs, System.Type)
   at System.Windows.WeakEventManager.DeliverEvent(System.Object, System.EventArgs)
   at ICSharpCode.AvalonEdit.Document.TextDocument.FireChangeEvents()
   at ICSharpCode.AvalonEdit.Document.TextDocument.EndUpdate()
   at ICSharpCode.AvalonEdit.Utils.CallbackOnDispose.Dispose()
   at ICSharpCode.AvalonEdit.Editing.SimpleSelection.ReplaceSelectionWithText(System.String)
   at ICSharpCode.AvalonEdit.Editing.EditingCommandHandler+<>c__DisplayClass3.<OnDelete>b__2(System.Object, System.Windows.Input.ExecutedRoutedEventArgs)
   at System.Windows.Input.CommandBinding.OnExecuted(System.Object, System.Windows.Input.ExecutedRoutedEventArgs)
   at System.Windows.Input.CommandManager.ExecuteCommandBinding(System.Object, System.Windows.Input.ExecutedRoutedEventArgs, System.Windows.Input.CommandBinding)
   at System.Windows.Input.CommandManager.FindCommandBinding(System.Windows.Input.CommandBindingCollection, System.Object, System.Windows.RoutedEventArgs, System.Windows.Input.ICommand, Boolean)
   at System.Windows.Input.CommandManager.FindCommandBinding(System.Object, System.Windows.RoutedEventArgs, System.Windows.Input.ICommand, Boolean)
   at System.Windows.Input.CommandManager.OnExecuted(System.Object, System.Windows.Input.ExecutedRoutedEventArgs)
   at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
   at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
   at System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs)
   at System.Windows.Input.RoutedCommand.ExecuteImpl(System.Object, System.Windows.IInputElement, Boolean)
   at System.Windows.Input.CommandManager.TranslateInput(System.Windows.IInputElement, System.Windows.Input.InputEventArgs)
   at System.Windows.UIElement.OnKeyDownThunk(System.Object, System.Windows.Input.KeyEventArgs)
   at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
   at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
   at System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(System.Windows.Interop.MSG ByRef, Boolean ByRef)
   at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(System.Windows.Interop.MSG ByRef, System.Windows.Input.ModifierKeys)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at System.Windows.Threading.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority, System.Delegate, System.Object)
   at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(System.Windows.Interop.MSG ByRef, Boolean ByRef)
   at System.Windows.Interop.ThreadMessageEventHandler.Invoke(System.Windows.Interop.MSG ByRef, Boolean ByRef)
   at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Application.RunDispatcher(System.Object)
   at System.Windows.Application.RunInternal(System.Windows.Window)
   at MarkdownEdit.App.Main()

Hmm. Just as I was about to submit the issue I noticed it's a CommonMark crash. However, I think I'll still log it here as it is perhaps something that is being trapped. I'll try writing a console repro and then submit the same thing to CommonMark.

Thanks;
Richard Moss

@mike-ward

This comment has been minimized.

Show comment
Hide comment
@mike-ward

mike-ward Jun 29, 2016

Owner

For documentation purposes the CommonMark options are:

OutputFormat = HTML;
TrackSourcePosition = true;
Owner

mike-ward commented Jun 29, 2016

For documentation purposes the CommonMark options are:

OutputFormat = HTML;
TrackSourcePosition = true;
@cyotek

This comment has been minimized.

Show comment
Hide comment
@cyotek

cyotek Jul 5, 2016

Thanks to @Knagis there's a new build of the CommonMark lib (1.13.2) that should resolve the original crash.

cyotek commented Jul 5, 2016

Thanks to @Knagis there's a new build of the CommonMark lib (1.13.2) that should resolve the original crash.

@mike-ward

This comment has been minimized.

Show comment
Hide comment
@mike-ward

mike-ward Jul 5, 2016

Owner

I'll try to get a new build out tonight.

Owner

mike-ward commented Jul 5, 2016

I'll try to get a new build out tonight.

@mike-ward mike-ward closed this Jul 6, 2016

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