Dompdf LFI (Local File Inclusion)
Input validation

I find this an unusual way to validate script parameters:


if [ -z "$1" ] || [ -z "$2" ]; then



It's more common to verify that there are exactly two parameters:

if [ $# != 2 ]; then


Note that this is not exactly the same as the original.
The original verifies that neither $1 and $2 is empty,
and it silently allows more than 2 parameters.

Why echo a sub-shell?

What is the purpose of this echo:


echo `curl --silent $URL`



Instead of simply:

curl --silent $URL


If the purpose is to join multiple lines into one, I would use tr instead:

curl --silent "$URL" | tr -d '\n'
# or
curl --silent "$URL" | tr '\n' ' '


Writing this way make the intention more clear.
Another advantage is streamlined processing.
Note also that I added double-quotes around the $URL used as command parameter, as a good rule of thumb to protect from unexpected word splitting and globbing.

One sed to rule them all

Instead of this:


sed 's/.*\[(//' | sed 's/)\].*//'



You can do multiple expressions with a single sed using multiple -e parameters:

sed -e 's/.*\[(//' -e 's/)\].*//'


I use the -e even with single expressions,
for maximum clarity.