Skip to content


Subversion checkout URL

You can clone with
Download ZIP


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

mcarpenter opened this Issue · 2 comments

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 >"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:"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:"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:"\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>""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)"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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.