diff options
author | Toon Claes <toon@iotcl.com> | 2017-10-18 13:19:34 +0200 |
---|---|---|
committer | Toon Claes <toon@iotcl.com> | 2017-10-18 13:19:34 +0200 |
commit | cc892541220ba2f1d8a17a88185ff4913d93777a (patch) | |
tree | 0b8c680e56a78d803b93d3dd19aaf4ee28391444 /lib/gitlab/encoding_helper.rb | |
parent | 1090514ab407b7faa894cbd9b6cd769c376a9b5d (diff) | |
download | gitlab-ce-cc892541220ba2f1d8a17a88185ff4913d93777a.tar.gz |
Remove unavailable characters when encoding page title to ISO-8859-1tc-page-title-encoding-fix
The Page-Title header has to be ISO-8859-1, so when converting the
title to that encoding, remove characters that are not available.
Closes gitlab-org/gitlab-ce#39179.
Diffstat (limited to 'lib/gitlab/encoding_helper.rb')
-rw-r--r-- | lib/gitlab/encoding_helper.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/gitlab/encoding_helper.rb b/lib/gitlab/encoding_helper.rb index 7b3483a7f96..0efeecd7d4a 100644 --- a/lib/gitlab/encoding_helper.rb +++ b/lib/gitlab/encoding_helper.rb @@ -64,6 +64,11 @@ module Gitlab end end + # Convert all characters to the desired encoding, and drop the characters not available in that encoding + def lossy_encode(message, encoding) + message.encode(encoding, invalid: :replace, undef: :replace, replace: '') + end + private def clean(message) |