Skip to content

Error on Markdown parsing with certain pattern

If a markdown text contains this pattern:

aaa/bbb~ ccc/ (without space after ~)

If I input this pattern correctly, it will become a 500 error and you won't see this issue.

This pattern will cause 500 error in source code/issue/wiki, but not in snippets. The error log is like:

ActionView::Template::Error (undefined method `labels' for nil:NilClass):
    22: .wiki-holder.prepend-top-default
    23:   .wiki
    24:     = preserve do
    25:       = render_wiki_content(@page)
  lib/banzai/filter/label_reference_filter.rb:23:in `block in references_in'
  lib/banzai/filter/label_reference_filter.rb:20:in `gsub'
  lib/banzai/filter/label_reference_filter.rb:20:in `references_in'
  lib/banzai/filter/abstract_reference_filter.rb:111:in `object_link_filter'
  lib/banzai/filter/abstract_reference_filter.rb:74:in `block in call'
  lib/banzai/filter/reference_filter.rb:99:in `block in replace_text_nodes_matching'
  lib/banzai/filter/reference_filter.rb:93:in `replace_text_nodes_matching'
  lib/banzai/filter/abstract_reference_filter.rb:73:in `call'
  lib/banzai/pipeline/base_pipeline.rb:21:in `block (2 levels) in singleton class'
  lib/banzai/renderer.rb:31:in `render_result'
  lib/banzai/renderer.rb:67:in `cacheless_render'
  lib/banzai/renderer.rb:26:in `render'
  lib/banzai.rb:3:in `render'
  app/helpers/gitlab_markdown_helper.rb:55:in `markdown'
  app/helpers/gitlab_markdown_helper.rb:111:in `render_wiki_content'
  app/views/projects/wikis/show.html.haml:25:in `block in _app_views_projects_wikis_show_html_haml___541807120774261926_159132060'
  app/views/projects/wikis/show.html.haml:24:in `_app_views_projects_wikis_show_html_haml___541807120774261926_159132060'
  app/controllers/projects/wikis_controller.rb:17:in `show'
  lib/gitlab/middleware/go.rb:16:in `call'

I'm not a ruby guy, sorry can't help solving it. Hope it will be solved soon.

Thanks.