diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e4341b..45a74a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.6.1 +## 07/12/2018 + +3. [](#bugfix) + * Fixed parsing tags other than links [#24](https://github.com/Sommerregen/grav-plugin-external-links/pull/24) (Fix loading of a href element) + # v1.6.0 ## 02/22/2018 diff --git a/LICENSE b/LICENSE index 581c4b1..4d877f4 100644 --- a/LICENSE +++ b/LICENSE @@ -27,7 +27,7 @@ using Grav External Links Plugin in any way. MIT LICENSE ----------- -Copyright (c) 2017 Benjamin Regler, https://github.com/sommerregen/grav-plugin-external-links +Copyright (c) 2017+ Benjamin Regler, https://github.com/sommerregen/grav-plugin-external-links Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 330b60d..599e508 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [![Grav External Links Plugin](assets/logo.png)][project] -[![Release](https://img.shields.io/github/release/sommerregen/grav-plugin-external-links.svg)][project] [![Issues](https://img.shields.io/github/issues/sommerregen/grav-plugin-external-links.svg)][issues] [![Dual license](https://img.shields.io/badge/dual%20license-MIT%2FGPL-blue.svg)](LICENSE "License") [![Flattr](https://api.flattr.com/button/flattr-badge-large.png)][flattr] [![PayPal](https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif)][paypal] +[![Release](https://img.shields.io/github/release/sommerregen/grav-plugin-external-links.svg)][project] [![Issues](https://img.shields.io/github/issues/sommerregen/grav-plugin-external-links.svg)][issues] [![Dual license](https://img.shields.io/badge/dual%20license-MIT%2FGPL-blue.svg)](LICENSE "License") > This plugin adds small icons to external and mailto links, informing users the link will take them to a new site or open their email client. @@ -172,12 +172,6 @@ After that please note: * Feature requests are more likely to get attention if you include a clearly described use case. * If you wish to submit a pull request, please make again sure that your request match the [guidelines for contributing](docs/CONTRIBUTING.md) and that you keep track of adding unit tests for any new or changed functionality. -### Support and donations - -If you like my project, feel free to support me via [![Flattr](https://api.flattr.com/button/flattr-badge-large.png)][flattr] or by sending me some bitcoins to [**1HQdy5aBzNKNvqspiLvcmzigCq7doGfLM4**][bitcoin]. - -Thanks! - ## License Copyright (c) 2017+ [Benjamin Regler][github]. See also the list of [contributors] who participated in this project. @@ -189,10 +183,6 @@ Copyright (c) 2017+ [Benjamin Regler][github]. See also the list of [contributor [github]: https://github.com/sommerregen/ "GitHub account from Benjamin Regler" [gpl-license]: http://opensource.org/licenses/GPL-3.0 "GPLv3 license" [mit-license]: http://www.opensource.org/licenses/mit-license.php "MIT license" - -[flattr]: https://flattr.com/submit/auto?user_id=Sommerregen&url=https://github.com/sommerregen/grav-plugin-external-links "Flatter my GitHub project" -[paypal]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SYFNP82USG3RN "Donate for my GitHub project using PayPal" -[bitcoin]: bitcoin:1HQdy5aBzNKNvqspiLvcmzigCq7doGfLM4?label=GitHub%20project "Donate for my GitHub project using BitCoin" [gnu]: https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/License_icon-gpl-88x31.svg/88px-License_icon-gpl-88x31.svg.png "GNU license - Some rights reserved" [project]: https://github.com/sommerregen/grav-plugin-external-links diff --git a/blueprints.yaml b/blueprints.yaml index 7d96cd3..6e2ea78 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: 'External Links' -version: '1.6.0' +version: '1.6.1' description: 'This plugin adds small icons to external and mailto links, informing users the link will take them to a new site or open their email client.' icon: 'external-link' author: diff --git a/classes/ExternalLinks.php b/classes/ExternalLinks.php index 00462d8..fca28ea 100644 --- a/classes/ExternalLinks.php +++ b/classes/ExternalLinks.php @@ -42,14 +42,19 @@ class ExternalLinks public function render($content, $options = [], $page = null) { // Get all tags and process them - $content = preg_replace_callback('~]*>.*?~i', + $content = preg_replace_callback('~]*)?>.*?~i', function($match) use ($options, $page) { // Load PHP built-in DOMDocument class if (($dom = $this->loadDOMDocument($match[0])) === null) { return $match[0]; } - $a = $dom->getElementsByTagName('a')->item(0); + // Check that there is really a link tag + $a = $dom->getElementsByTagName('a'); + if ($a->length == 0) { + return $match[0]; + } + $a = $a->item(0); // Process links with non-empty href attribute $href = $a->getAttribute('href'); diff --git a/external_links.php b/external_links.php index 99f10b8..9ca7ca4 100644 --- a/external_links.php +++ b/external_links.php @@ -1,6 +1,6 @@ * @author Benjamin Regler - * @copyright 2017, Benjamin Regler + * @copyright 2017+, Benjamin Regler * @license MIT * @license GPLv3 */