Skip to content

Commit

Permalink
Now filter html external references (eg. images to arbitrary urls). T…
Browse files Browse the repository at this point in the history
…his ensures that arbitrary urls are not fetched from the server during PDF creation.
  • Loading branch information
collectiveaccess committed Sep 25, 2021
1 parent 8362ed4 commit aaf573e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/conf/app.conf
Expand Up @@ -2109,6 +2109,10 @@ service_view_path = <ca_app_dir>/service/views
# -----------------------------------
purify_all_text_input = 1

# Allow external URL references (eg. images) in HTML text input?
# Leaving this enabled may be a security risk
purify_allow_external_references = 0

# -----------------------------------
# Paths to other config files
# -----------------------------------
Expand Down
6 changes: 5 additions & 1 deletion app/lib/BaseModel.php
Expand Up @@ -551,7 +551,11 @@ public function purify($pb_purify=null) {
* @return HTMLPurifier Returns instance
*/
static public function getPurifier() {
if (!BaseModel::$html_purifier) { BaseModel::$html_purifier = new HTMLPurifier(); }
if (!BaseModel::$html_purifier) {
$config = HTMLPurifier_Config::createDefault();
$config->set('URI.DisableExternalResources', !Configuration::load()->get('purify_allow_external_references'));
BaseModel::$html_purifier = new HTMLPurifier($config);
}
return BaseModel::$html_purifier;
}
# --------------------------------------------------------------------------------
Expand Down

0 comments on commit aaf573e

Please sign in to comment.