Skip to content

Commit

Permalink
Merge pull request #1030 from jorbie/add-allow-option
Browse files Browse the repository at this point in the history
add support for --allow option
  • Loading branch information
unixmonkey authored Aug 19, 2022
2 parents 3492a51 + 3121854 commit ced04ac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class ThingsController < ApplicationController
# define as true the key 'disable_local_file_access' or 'enable_local_file_access', not both
disable_local_file_access: true,
enable_local_file_access: false, # must be true when using wkhtmltopdf > 0.12.6
allow: ["#{Rails.root}/public"], # could be an array or a single string

disable_smart_shrinking: true,
use_xserver: true,
Expand Down
3 changes: 2 additions & 1 deletion lib/wicked_pdf/option_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ def parse_others(options)
encoding
user_style_sheet
viewport_size
window_status])
window_status
allow])
r += make_options(options, %i[cookie
post], '', :name_value)
r += make_options(options, %i[redirect_delay
Expand Down
7 changes: 6 additions & 1 deletion test/unit/wicked_pdf_option_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class WickedPdfOptionParserTest < ActiveSupport::TestCase
assert_equal "--#{o.to_s.tr('_', '-')} opts", parse_options(o => 'opts').strip
end

%i[allow].each do |o|
assert_equal "--#{o.to_s.tr('_', '-')} opts", parse_options(o => 'opts').strip
assert_equal "--#{o.to_s.tr('_', '-')} opts1 --#{o.to_s.tr('_', '-')} opts2", parse_options(o => %w[opts1 opts2]).strip
end

%i[cookie post].each do |o|
assert_equal "--#{o.to_s.tr('_', '-')} name value", parse_options(o => 'name value').strip

Expand All @@ -90,7 +95,7 @@ class WickedPdfOptionParserTest < ActiveSupport::TestCase
%i[
book default_header disable_javascript grayscale lowquality
enable_plugins disable_internal_links disable_external_links
print_media_type disable_smart_shrinking use_xserver no_background
print_media_type disable_smart_shrinking use_xserver no_background disable_local_file_access
].each do |o|
assert_equal "--#{o.to_s.tr('_', '-')}", parse_options(o => true).strip
end
Expand Down

0 comments on commit ced04ac

Please sign in to comment.