Ruby-RTF icon indicating copy to clipboard operation
Ruby-RTF copied to clipboard

Nonbreaking space directive "\~" raises NoMethodError

Open toupeira opened this issue 1 year ago • 0 comments

Ran into this while parsing some RTFs in the wild, here's a minimal test case:

{\rtf1 \~}
$ RubyRTF::VERSION
=> "0.0.5"
$ RubyRTF::Parser.new.parse('{\rtf1 \~}')
NoMethodError: undefined method `[]' for nil:NilClass
from [...]/gems/ruby-rtf-0.0.5/lib/ruby-rtf/parser.rb:107:in `parse_control'

Seems like \~ should be a valid directive according to https://www.biblioscape.com/rtf15_spec.htm?

My workaround for now is just to replace instances of \~ with whitespace characters before passing them to RubyRTF::Parser.

toupeira avatar Feb 27 '24 16:02 toupeira