Skip to content

Commit c840567

Browse files
committed
fix. r7 code review
Signed-off-by: RAMELLA Sebastien <[email protected]>
1 parent 73208fd commit c840567

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

modules/auxiliary/fileformat/maldoc_in_pdf_polyglot.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def create_pdf(mht)
118118

119119
# saving the file
120120
ltype = "auxiliary.fileformat.#{shortname}"
121-
fname = File.basename(datastore['FILENAME']).sub(File.extname(datastore['FILENAME']), datastore['OUTPUT_EXT'])
121+
fname = File.basename(datastore['FILENAME'], '*') + datastore['OUTPUT_EXT']
122122
path = store_local(ltype, nil, pdf, fname)
123123

124124
print_good("The file '#{fname}' is stored at '#{path}'")
@@ -184,7 +184,7 @@ def inject_pdf(pdf_path, mht)
184184

185185
# saving the file
186186
ltype = "auxiliary.fileformat.#{shortname}"
187-
fname = File.basename(datastore['FILENAME']).sub(File.extname(datastore['FILENAME']), datastore['OUTPUT_EXT'])
187+
fname = File.basename(datastore['FILENAME'], '*') + datastore['OUTPUT_EXT']
188188
path = store_local(ltype, nil, pdf, fname)
189189

190190
print_good("The file '#{fname}' is stored at '#{path}'")
@@ -198,16 +198,13 @@ def rand_pdfheader
198198

199199
def run
200200
content = File.read(datastore['FILENAME'])
201-
if content&.empty?
202-
fail_with(Failure::BadConfig, 'The MHT file content is empty')
203-
end
201+
fail_with(Failure::BadConfig, 'The MHT file content is empty') if content&.empty?
204202

205203
# if no pdf injected is provided, create new PDF from template
206-
if datastore['INJECTED_PDF'].nil? || datastore['INJECTED_PDF'].empty?
204+
if datastore['INJECTED_PDF'].blank?
207205
print_status('INJECTED_PDF not provided, creating the PDF from scratch')
208-
if datastore['MESSAGE_PDF'].nil? || datastore['MESSAGE_PDF'].empty?
209-
fail_with(Failure::BadConfig, 'No MESSAGE_PDF provided')
210-
end
206+
fail_with(Failure::BadConfig, 'No MESSAGE_PDF provided') if datastore['MESSAGE_PDF'].blank?
207+
211208
create_pdf(content)
212209
else
213210
print_status("PDF creation using '#{File.basename(datastore['INJECTED_PDF'])}' as template")

0 commit comments

Comments
 (0)