mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
This commit is contained in:
committed by
Guo Xiang Tan
parent
4e1f25197d
commit
30990006a9
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# For some reason safe buffer is getting invalid encoding in some cases
|
||||
# we work around the issue and log the problems
|
||||
#
|
||||
@@ -15,9 +17,9 @@ class ActiveSupport::SafeBuffer
|
||||
raise
|
||||
else
|
||||
|
||||
encoding_diags = "internal encoding #{Encoding.default_internal}, external encoding #{Encoding.default_external}"
|
||||
encoding_diags = +"internal encoding #{Encoding.default_internal}, external encoding #{Encoding.default_external}"
|
||||
|
||||
unless encoding == Encoding::UTF_8
|
||||
if encoding != Encoding::UTF_8
|
||||
encoding_diags << " my encoding is #{encoding} "
|
||||
|
||||
self.force_encoding("UTF-8")
|
||||
@@ -28,7 +30,7 @@ class ActiveSupport::SafeBuffer
|
||||
Rails.logger.warn("Encountered a non UTF-8 string in SafeBuffer - #{self} - #{encoding_diags}")
|
||||
end
|
||||
|
||||
unless value.encoding == Encoding::UTF_8
|
||||
if value.encoding != Encoding::UTF_8
|
||||
|
||||
encoding_diags << " attempted to append encoding #{value.encoding} "
|
||||
|
||||
|
||||
Reference in New Issue
Block a user