For some reason (maybe copy & paste), we ended up with a text field containing \u0002 char (Start of Text), and this broke document generation with Sablon
Minimum reproducible test case
# frozen_string_literal: true
require 'bundler/inline'
begin
gemfile(true) do
source 'https://rubygems.org'
gem 'sablon'
end
require 'sablon'
rescue Gem::LoadError => e
puts "\nMissing Dependency:\n#{e.backtrace.first} #{e.message}"
rescue LoadError => e
puts "\nError:\n#{e.backtrace.first} #{e.message}"
exit 1
end
template = Sablon.template(File.expand_path('./cv_template.docx'))
context = {
title: "\u0002",
skills: [],
education: [],
career: [],
referees: []
}
template.render_to_file File.expand_path('./output.docx'), context
cv template is the same file as: https://github.com/senny/sablon/blob/master/test/fixtures/cv_template.docx
This is a problem with unicode chars from 1 (0001) to 31 (001F) except, without surprises, for:
- horizontal tab
0009
- line feed
000a
- carriage return
000d
Expected output
The template without content
Actual output
An empty file
Workarounds
I've tried Sablon.content(:string, "\u0002") without success.
Sanitizing the input will work, but there is always the chance to forget a field, so I was wondering if this can be fixed in Sablon itself
For some reason (maybe copy & paste), we ended up with a text field containing
\u0002char (Start of Text), and this broke document generation with SablonMinimum reproducible test case
cv template is the same file as: https://github.com/senny/sablon/blob/master/test/fixtures/cv_template.docx
This is a problem with unicode chars from 1 (
0001) to 31 (001F) except, without surprises, for:0009000a000dExpected output
The template without content
Actual output
An empty file
Workarounds
I've tried
Sablon.content(:string, "\u0002")without success.Sanitizing the input will work, but there is always the chance to forget a field, so I was wondering if this can be fixed in Sablon itself