≡

wincent.dev

  • Products
  • Blog
  • Wiki
  • Issues
You are viewing an historical archive of past issues. Please report new issues to the appropriate project issue tracker on GitHub.
Home » Issues » Bug #1289

Bug #1289: Exception raised for empty links

Kind bug
Product wikitext
When Created 2009-04-27T17:04:53Z, updated 2009-04-28T11:53:52Z
Status closed
Reporter Greg Hurrell
Tags no tags

Description

Just noticed this in the live preview while editing a wiki article ("Updating to nginx 0.6.36 with the nginx upload module 2.0.9"):

ActionView::TemplateError (can't convert nil into String) on line #2 of app/views/articles/_preview.js.haml:
1: ="=== #{@article.title} ===".w
2: =@article.body.w :base_heading_level => 2

    wikitext (1.5.2) [v] lib/wikitext/string.rb:19:in `parse'
    wikitext (1.5.2) [v] lib/wikitext/string.rb:19:in `w'
    app/views/articles/_preview.js.haml:2:in `_run_haml_app47views47articles47_preview46js46haml_locals_object_preview'
    haml (2.0.9) [v] lib/haml/helpers/action_view_mods.rb:14:in `render'
    app/controllers/articles_controller.rb:45:in `create'
    app/controllers/articles_controller.rb:29:in `create'
    haml (2.0.9) [v] rails/./lib/sass/plugin/rails.rb:19:in `process'

Rendering /public/500.html (500 Internal Server Error)

Not sure why nil turned up — nor where; was it that the wikitext module itself returned nil? — but I should check out this code path anyway to make the template more robust in the face of such input.

Comments

  1. Greg Hurrell 2009-04-27T17:06:12Z

    Status changed:

    • From: New
    • To: Open
  2. Greg Hurrell 2009-04-27T17:07:46Z

    Looks like I've definitely found something that makes the wikitext parser choke. Posting the full log excerpt caused issues#show to freak out as well (I had to edit the description to remove the snippet). Here's the exception:

    ActionView::TemplateError (can't convert nil into String) on line #50 of app/views/issues/show.html.haml:
    47:         -if @issue.description.blank?
    48:           none
    49:         -else
    50:           =@issue.description.w :base_heading_level => 1
    51:     -if admin?
    52:       %tr
    53:         %th Public?

    Looks like I might have to reassign this to the wikitext module...

  3. Greg Hurrell 2009-04-27T17:10:32Z

    Product changed:

    • From: wincent.dev
    • To: wikitext
  4. Greg Hurrell 2009-04-27T17:14:33Z

    I can reproduce this in irb with this dastardly string:

    "I wasn't going to update to [[nginx 0.6.36]] but seeing as I am about to start testing the [[nginx upload module]] (see [/issues/1193 ticket #1193]) and I would have to rebuild [[nginx]] anyway for that, I thought I'd use the latest stable release.\n\n= Building on [[Mac OS X]] [[Leopard]] 10.5.6 =\n\n== Build process ==\n\n<pre>wget http://www.grid.net.ru/nginx/download/nginx_upload_module-2.0.9.tar.gz\ntar xzvf nginx_upload_module-2.0.9.tar.gz \nwget http://sysoev.ru/nginx/nginx-0.6.36.tar.gz\ntar xzvf nginx-0.6.36.tar.gz\ncd nginx-0.6.36\n./configure --prefix=/usr/local/nginx \\\n --with-http_ssl_module \\\n --add-module=../nginx_upload_module-2.0.9\nmake\nsudo make install</pre>\n\nThe build is pretty much identical to the normal process (see \"[[]]\" for example), but you'll see something like this at the configuration stage:\n\n<pre>configuring additional modules\nadding module in ../nginx_upload_module-2.0.9\n + ngx_http_upload_module was configured</pre>\n\n== Changes ==\n\n\n"

    Stick that in a variable, bad, and try running it through the parser:

    >> bad.w
    TypeError: can't convert nil into String
    	from /Library/Ruby/Gems/1.8/gems/wikitext-1.5.2/lib/wikitext/string.rb:19:in `parse'
    	from /Library/Ruby/Gems/1.8/gems/wikitext-1.5.2/lib/wikitext/string.rb:19:in `w'
    	from (irb):6
  5. Greg Hurrell 2009-04-27T17:15:33Z

    Here we go, here's the minimal test case:

    >> "[[]]".w
    TypeError: can't convert nil into String
    	from /Library/Ruby/Gems/1.8/gems/wikitext-1.5.2/lib/wikitext/string.rb:19:in `parse'
    	from /Library/Ruby/Gems/1.8/gems/wikitext-1.5.2/lib/wikitext/string.rb:19:in `w'
    	from (irb):16
  6. Greg Hurrell 2009-04-27T18:26:50Z

    Summary changed:

    • From: Exception raised while rendering app/views/articles/_preview.js.haml
    • To: Exception raised for empty links
  7. Greg Hurrell 2009-04-27T18:28:34Z

    So looks like the "link target" can't be empty/nil, although the "link text" can:

    $ irb -r wikitext -r wikitext/string
    >> "[[]]".w
    TypeError: can't convert nil into String
    	from /Library/Ruby/Gems/1.8/gems/wikitext-1.5.2/lib/wikitext/string.rb:19:in `parse'
    	from /Library/Ruby/Gems/1.8/gems/wikitext-1.5.2/lib/wikitext/string.rb:19:in `w'
    	from (irb):1
    >> "[[|]]".w
    TypeError: can't convert nil into String
    	from /Library/Ruby/Gems/1.8/gems/wikitext-1.5.2/lib/wikitext/string.rb:19:in `parse'
    	from /Library/Ruby/Gems/1.8/gems/wikitext-1.5.2/lib/wikitext/string.rb:19:in `w'
    	from (irb):2
    >> "[[a|]]".w
    => "<p><a href=\"/wiki/a\">a</a></p>\n"
    >> "[[|b]]".w
    TypeError: can't convert nil into String
    	from /Library/Ruby/Gems/1.8/gems/wikitext-1.5.2/lib/wikitext/string.rb:19:in `parse'
    	from /Library/Ruby/Gems/1.8/gems/wikitext-1.5.2/lib/wikitext/string.rb:19:in `w'
    	from (irb):4
  8. Greg Hurrell 2009-04-28T06:43:25Z

    Ok, now fixed and released in 1.5.3.

  9. Greg Hurrell 2009-04-28T06:43:30Z

    Status changed:

    • From: Open
    • To: Closed
  10. Greg Hurrell 2009-04-28T11:53:52Z

    The new version has been deployed to the site. Note how you can now use invalid links (eg. [[]], [[|]], [[|foo]]) with no ill effects.

Add a comment

Comments are now closed for this issue.

  • contact
  • legal

Menu

  • Blog
  • Wiki
  • Issues
  • Snippets