New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid byte sequence in UTF-8 #1163

Closed
vsuhachev opened this Issue Apr 19, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@vsuhachev

vsuhachev commented Apr 19, 2017

Syntax error in template cause fail in error handler. See first crashlog

After use scrub inside Nanoc::CLI::StreamCleaners::ANSIColors.clean i've got second crashlog. It seems that the problem occurs when nanoc extracts substring from UTF-8 string. Wrong extraction breaks the multibyte sequence of UTF-8 glyph

First:

Captain! We’ve been hit!

Message:


Captain! We’ve been hit!

Message:

ArgumentError: invalid byte sequence in UTF-8

Stack trace:

  0. /home/vs/code/rb/nanoc/lib/nanoc/cli/stream_cleaners/ansi_colors.rb:8:in `gsub'
  1. /home/vs/code/rb/nanoc/lib/nanoc/cli/stream_cleaners/ansi_colors.rb:8:in `clean'
  2. /home/vs/code/rb/nanoc/lib/nanoc/cli/cleaning_stream.rb:150:in `block in _nanoc_clean'
  3. /home/vs/code/rb/nanoc/lib/nanoc/cli/cleaning_stream.rb:150:in `each'
  4. /home/vs/code/rb/nanoc/lib/nanoc/cli/cleaning_stream.rb:150:in `reduce'
  5. /home/vs/code/rb/nanoc/lib/nanoc/cli/cleaning_stream.rb:150:in `_nanoc_clean'
  6. /home/vs/code/rb/nanoc/lib/nanoc/cli/cleaning_stream.rb:86:in `block (2 levels) in puts'
  7. /home/vs/code/rb/nanoc/lib/nanoc/cli/cleaning_stream.rb:86:in `map'
  8. /home/vs/code/rb/nanoc/lib/nanoc/cli/cleaning_stream.rb:86:in `block in puts'
  9. /home/vs/code/rb/nanoc/lib/nanoc/cli/cleaning_stream.rb:154:in `_nanoc_swallow_broken_pipe_errors_while'
  ... 21 more lines omitted. See full crash log for details.

Second:

Captain! We’ve been hit!

Message:

SyntaxError: (__TEMPLATE__):21: syntax error, unexpected '[', expecting '('
�стровыйНомер])&.[:Номер]))); 
                              ^
(__TEMPLATE__):29: syntax error, unexpected keyword_end, expecting ')'
 << ("</td></tr>".freeze); end; _erbout << ("</tbody></table
                              ^
(__TEMPLATE__):31: syntax error, unexpected keyword_end, expecting ')'
end;end;end;end
   ^

Stack trace:

  0. /home/vs/.rvm/gems/ruby-2.4.0/gems/tilt-2.0.7/lib/tilt/template.rb:273:in `class_eval'
  1. /home/vs/.rvm/gems/ruby-2.4.0/gems/tilt-2.0.7/lib/tilt/template.rb:273:in `compile_template_method'
  2. /home/vs/.rvm/gems/ruby-2.4.0/gems/tilt-2.0.7/lib/tilt/template.rb:236:in `block in compiled_method'
  3. /home/vs/.rvm/gems/ruby-2.4.0/gems/tilt-2.0.7/lib/tilt/template.rb:235:in `synchronize'
  4. /home/vs/.rvm/gems/ruby-2.4.0/gems/tilt-2.0.7/lib/tilt/template.rb:235:in `compiled_method'
  5. /home/vs/.rvm/gems/ruby-2.4.0/gems/tilt-2.0.7/lib/tilt/template.rb:169:in `evaluate'
  6. /home/vs/.rvm/gems/ruby-2.4.0/gems/tilt-2.0.7/lib/tilt/template.rb:109:in `render'
  7. /home/vs/code/rb/nanoc/lib/nanoc/filters/slim.rb:23:in `run'
  8. /home/vs/code/rb/nanoc/lib/nanoc/base/services/filter.rb:150:in `setup_and_run'
  9. /home/vs/code/rb/nanoc/lib/nanoc/base/services/executor.rb:74:in `layout'
  ... 12 more lines omitted. See full crash log for details.
@ddfreyne

This comment has been minimized.

Show comment
Hide comment
@ddfreyne

ddfreyne Apr 20, 2017

Member

The stream cleaners should indeed support malformed strings. String#scrub seems like a good use! Will fix.

Member

ddfreyne commented Apr 20, 2017

The stream cleaners should indeed support malformed strings. String#scrub seems like a good use! Will fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment