undefined method `strip' for nil:NilClass (NoMethodError) #66

mcarpenter opened this Issue Oct 18, 2012 · 2 comments


None yet

3 participants


Occurs with either 0.6.0 or 0.6.1 (where is the source for 0.6.1?). Suspect related to email header processing.

Minimal test case:

ruby-1.9.3-p286 :001 > require 'maruku'
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead.
 => true 
ruby-1.9.3-p286 :002 > Maruku.new("A\n\n: \n\n")
NoMethodError: undefined method `strip' for nil:NilClass
        from /usr/share/ruby-rvm/gems/ruby-1.9.3-p286/gems/maruku-0.6.0/lib/maruku/string_utils.rb:71:in `normalize_key_and_value'
        from /usr/share/ruby-rvm/gems/ruby-1.9.3-p286/gems/maruku-0.6.0/lib/maruku/string_utils.rb:59:in `block in parse_email_headers'
        from /usr/share/ruby-rvm/gems/ruby-1.9.3-p286/gems/maruku-0.6.0/lib/maruku/string_utils.rb:55:in `each'
        from /usr/share/ruby-rvm/gems/ruby-1.9.3-p286/gems/maruku-0.6.0/lib/maruku/string_utils.rb:55:in `parse_email_headers'
        from /usr/share/ruby-rvm/gems/ruby-1.9.3-p286/gems/maruku-0.6.0/lib/maruku/input/parse_doc.rb:29:in `parse_doc'
        from /usr/share/ruby-rvm/gems/ruby-1.9.3-p286/gems/maruku-0.6.0/lib/maruku/maruku.rb:30:in `initialize'
        from (irb):2:in `new'
        from (irb):2
        from /usr/bin/irb:12:in `<main>'
ruby-1.9.3-p286 :003 > 

Use case:

Maruku.new("Group not known\n\n        foo: bar,baz\n\n").to_html

Expected output (approx):

=> "<p>Group not known</p>\n\n<pre><code>    foo: bar,baz</code></pre>"

Cheesy workaround:

Maruku.new("Group not known:\n\n        foo: bar,baz\n\n").to_html
                           ^ here
=> "<p>Group not known:</p>\n\n<pre><code>    foo: bar,baz</code></pre>"

Email header parsing can be disabled by prepending a "\n" to the text:

Maruku.new("\nGroup not known\n\n        foo: bar,baz\n\n").to_html
=> "<p>Group not known</p>\n\n<pre><code>    foo: bar,baz</code></pre>"

Maruku.new("A\n\n: \n\n")
NoMethodError: undefined method
strip' for nil:NilClass`

0.61 is pretty broken.

With the main branch, you should get the "correct" (but perhaps undesired)

 Maruku.new("A\n\n: \n\n").to_html
=> ""

Closing because this works as expected on master. Tracking the weird metadata stuff in #16. Source for 0.6.1 is on the iconv_patch branch btw.

@bhollis bhollis closed this Dec 31, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment