diff options
author | Stan Hu <stanhu@gmail.com> | 2016-01-13 07:05:28 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-01-20 07:07:53 -0800 |
commit | a10ab94b068c31601c7d4ab0062b9d567af6cee2 (patch) | |
tree | 5e61d028dd9e52c79edfc52515cec3410a4ca846 /lib/banzai | |
parent | f8f96994f7aa53b1588762266bf60418960cf30d (diff) | |
download | gitlab-ce-a10ab94b068c31601c7d4ab0062b9d567af6cee2.tar.gz |
Gracefully handle invalid UTF-8 sequences in Markdown linksfix-error-500-with-invalid-utf8
Closes #6077
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/reference_filter.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/banzai/filter/reference_filter.rb b/lib/banzai/filter/reference_filter.rb index 20bd4f7ee6e..3637b1bac94 100644 --- a/lib/banzai/filter/reference_filter.rb +++ b/lib/banzai/filter/reference_filter.rb @@ -133,6 +133,7 @@ module Banzai next unless link && text link = CGI.unescape(link) + next unless link.force_encoding('UTF-8').valid_encoding? # Ignore ending punctionation like periods or commas next unless link == text && text =~ /\A#{pattern}/ @@ -170,6 +171,7 @@ module Banzai next unless link && text link = CGI.unescape(link) + next unless link.force_encoding('UTF-8').valid_encoding? next unless link && link =~ /\A#{pattern}\z/ html = yield link, text |