From bfbe4ce1b847ade2df074b1df5900b1daa3a2e7f Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 4 Jun 2020 14:42:38 -0600 Subject: [PATCH] option to control supported attributes in markdown links Signed-off-by: Andy Miller --- CHANGELOG.md | 2 ++ system/blueprints/config/system.yaml | 10 ++++++++++ system/config/system.yaml | 6 ++++++ system/src/Grav/Common/Page/Markdown/Excerpts.php | 3 ++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37fe33e86..9ad0ba69b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # v1.6.26 ## mm/dd/2020 +1. [](#improved) + * Added new configuration option to control the supported attributes in markdown links [#2882](https://github.com/getgrav/grav/issues/2882) 1. [](#bugfix) * Fixed blueprint for `system.pages.hide_empty_folders` [#1925](https://github.com/getgrav/grav/issues/2925) diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index 30256be35..8899c2854 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -515,6 +515,16 @@ form: validate: type: bool + pages.markdown.valid_link_attributes: + type: selectize + size: large + label: PLUGIN_ADMIN.VALID_LINK_ATTRIBUTES + help: PLUGIN_ADMIN.VALID_LINK_ATTRIBUTES_HELP + placeholder: "rel, target, id, class, classes" + classes: fancy + validate: + type: commalist + caching: type: tab title: PLUGIN_ADMIN.CACHING diff --git a/system/config/system.yaml b/system/config/system.yaml index f11fe53be..438d0e326 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -59,6 +59,12 @@ pages: special_chars: # List of special characters to automatically convert to entities '>': 'gt' '<': 'lt' + valid_link_attributes: # Valid attributes to pass through via markdown links + - rel + - target + - id + - class + - classes types: [html,htm,xml,txt,json,rss,atom] # list of valid page types append_url_extension: '' # Append page's extension in Page urls (e.g. '.html' results in /path/page.html) expires: 604800 # Page expires time in seconds (604800 seconds = 7 days) diff --git a/system/src/Grav/Common/Page/Markdown/Excerpts.php b/system/src/Grav/Common/Page/Markdown/Excerpts.php index eaa13cbe8..b4ac69d88 100644 --- a/system/src/Grav/Common/Page/Markdown/Excerpts.php +++ b/system/src/Grav/Common/Page/Markdown/Excerpts.php @@ -87,7 +87,7 @@ class Excerpts ); // Valid attributes supported. - $valid_attributes = ['rel', 'target', 'id', 'class', 'classes']; + $valid_attributes = Grav::instance()['config']->get('system.pages.markdown.valid_link_attributes'); // Unless told to not process, go through actions. if (array_key_exists('noprocess', $actions)) { @@ -232,6 +232,7 @@ class Excerpts $url_parts = is_string($url) ? $this->parseUrl($url) : $url; $actions = []; + // if there is a query, then parse it and build action calls if (isset($url_parts['query'])) { $actions = array_reduce(