diff options
author | Robert Speicher <robert@gitlab.com> | 2016-01-20 19:03:32 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-01-20 19:03:32 +0000 |
commit | a8a65afe1e953ce3a9fc151f9e033b99fc568fad (patch) | |
tree | 79543d436a84739fbda049d89cfe685c741fc81d | |
parent | e3c43ca7d0c6353709456af05d0d65a2fa05b3d0 (diff) | |
parent | a10ab94b068c31601c7d4ab0062b9d567af6cee2 (diff) | |
download | gitlab-ce-a8a65afe1e953ce3a9fc151f9e033b99fc568fad.tar.gz |
Merge branch 'fix-error-500-with-invalid-utf8' into 'master'
Gracefully handle invalid UTF-8 sequences in Markdown links
Closes #6077
See merge request !2382
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | lib/banzai/filter/reference_filter.rb | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG index 03fce7e2157..cd147dc7662 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,7 @@ v 8.4.0 (unreleased) - Autocomplete data is now always loaded, instead of when focusing a comment text area - Improved performance of finding issues for an entire group - Added custom application performance measuring system powered by InfluxDB + - Gracefully handle invalid UTF-8 sequences in Markdown links (Stan Hu) - Bump fog to 1.36.0 (Stan Hu) - Add user's last used IP addresses to admin page (Stan Hu) - Add housekeeping function to project settings page 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 |