# File lib/mail/encodings.rb, line 115 def Encodings.value_decode(str) # Optimization: If there's no encoded-words in the string, just return it return str unless str.index("=?") str = str.gsub(/\?=(\s*)=\?/, '?==?') # Remove whitespaces between 'encoded-word's # Split on white-space boundaries with capture, so we capture the white-space as well str.split(/([ \t])/).map do |text| if text.index('=?') != 0 text else # Join QP encoded-words that are adjacent to avoid decoding partial chars text.gsub!(/\?\=\=\?.+?\?[Qq]\?/m, '') if text =~ /\?==\?/ # Separate encoded-words with a space, so we can treat them one by one text.gsub!(/\?\=\=\?/, '?= =?') text.split(/ /).map do |word| case when word.to_str =~ /=\?.+\?[Bb]\?/m b_value_decode(word) when text.to_str =~ /=\?.+\?[Qq]\?/m q_value_decode(word) else word.to_str end end end end.join("") end