NAME

WeBWorK::PG::SafeGD - Restrict GD::Image new method file path arguments to permitted_read_dir.

DESCRIPTION

GD is shared into the safe compartment for graphing macros (via WWPlot and the PGgraphmacros.pl macro). Several of the GD::Image methods take a file path argument and open it directly, with no restriction (new, newFromPng, newFromJpeg, newFromGif, newFromTiff, newFromXbm, newFromWebp, newFromHeif, newFromWBMP, newFromBmp, newFromGd, newFromGd2, newFromGd2Part, and newFromXpm). The restrict method in this package ensures that if those methods are called on an unsafe path (a path not in the permitted_read_dir), the methods do not reveal anything about the existence or lack thereof for the file path argument. The WWPlot package does not use these path-taking forms (only the numeric-size constructor is used).

restrict patches the GD::Image symbol table in place, so it only needs to run once per process, after GD itself has been loaded.