about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorBen Lubar <github@lubar.me>2020-05-28 05:47:40 -0500
committerGitHub <noreply@github.com>2020-05-28 12:47:40 +0200
commitead09f5ddc73034fcd573b459868dd1ca13b647a (patch)
treeed2f828f33f44268a05377b6907f7af37d253677 /app
parentc8cee24cb34fadf5d3887346f5b9333e0036adf6 (diff)
Fix exception when trying to serialize posts with <a> tags in them without hrefs (#1334)
* fix exception when trying to serialize posts with <a> tags in them without hrefs

* Add tests

Co-authored-by: Thibaut Girka <thib@sitedethib.com>
Diffstat (limited to 'app')
-rw-r--r--app/lib/sanitize_config.rb2
-rw-r--r--app/lib/tag_manager.rb1
2 files changed, 2 insertions, 1 deletions
diff --git a/app/lib/sanitize_config.rb b/app/lib/sanitize_config.rb
index 34793ed93..dfd8b9f91 100644
--- a/app/lib/sanitize_config.rb
+++ b/app/lib/sanitize_config.rb
@@ -55,7 +55,7 @@ class Sanitize
     end
 
     LINK_REL_TRANSFORMER = lambda do |env|
-      return unless env[:node_name] == 'a'
+      return unless env[:node_name] == 'a' and env[:node]['href']
 
       node = env[:node]
 
diff --git a/app/lib/tag_manager.rb b/app/lib/tag_manager.rb
index d06bea059..29dde128c 100644
--- a/app/lib/tag_manager.rb
+++ b/app/lib/tag_manager.rb
@@ -32,6 +32,7 @@ class TagManager
 
   def local_url?(url)
     uri    = Addressable::URI.parse(url).normalize
+    return false unless uri.host
     domain = uri.host + (uri.port ? ":#{uri.port}" : '')
 
     TagManager.instance.web_domain?(domain)