dmgerman / ninka

a license identification tool for Source Code
http://ninka.turingmachine.org
GNU General Public License v2.0
105 stars 31 forks source link

Handle special file names. #32

Open wyhfrank opened 8 years ago

wyhfrank commented 8 years ago

Special characters in file name

Files with special characters in their names should be handled correctly now.

Ninka has a module named FileCleaner.pm to clean up input file names with special characters such as ', $, ; and `(space). This file name is passed as an argument to external programs (eithercommentsorhead) usingopen3()`.

However, the command for the external call was constructed by quoting command name and arguments together, for example "head -$count_lines $input_file". In such way, the program will not execute correctly if $input_file contains special characters which are not cleaned up in the previous step (such as < and ().

What I did is split the command name and arguments into an array and pass it to open3(). Now the file names will be handled correctly and we don't need FileCleaner.pm any more, thus removed.

Another minor improvement

Die the program if the input file does not exist, to suppress the error message:

Use of uninitialized value $license_result in concatenation (.) or string at ./bin/ninka line 14.