New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed "can't modify frozen String" crash (bsc#1125006) #421
Conversation
Nice catch, @lslezak
I am still wondering how do you realized about that? I did the below unsuccessful dummy test require "yast"
require "yast/i18n"
class SimpleRegistrationTest
include Yast::I18n
def initialize
textdomain "registration"
end
end
Another question, means that that could we get more Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍, just a grammar nitpicking.
allow(subject).to receive(:_), &:freeze | ||
end | ||
|
||
context "when the there is an registered but not installed product" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: "When the there is an registered but not installed product"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I edited the text, but forgot some leftovers... thanks!
It depends whether the translation for the message is available or not. Translation Available> rpm -q yast2-trans-cs
yast2-trans-cs-84.87.20180514.157a0650d-lp150.1.1.noarch
> LC_ALL=cs_CZ.UTF-8 ruby -ryast -e 'include Yast::I18n; textdomain "base"; puts _("&Yes"); puts _("&Yes").frozen?'
&Ano
true So the result is a frozen translated string. Translation Not Available> rpm -q yast2-trans-es
package yast2-trans-es is not installed
> LC_ALL=es_ES.UTF-8 ruby -ryast -e 'include Yast::I18n; textdomain "base"; puts _("&Yes"); puts _("&Yes").frozen?'
&Yes
false In this case you'll get the original untranslated and not frozen string. The problem is that when running the unit tests in Travis, Jenkins or in OBS no translation is installed and the tests run in English locale. However, on users system the translations are usually available. That means it's hard to test it. I'll open the topic at yast-devel@, a possible solution would be to change - found ? Translation._(str) : str
+ found ? Translation._(str) : str.freeze at https://github.com/yast/yast-ruby-bindings/blob/4652448963160abc234d1199f06bf10f08989cf5/src/ruby/yast/i18n.rb#L63 so it behaves consistently. |
String
returned from gettext is frozen and cannot be modified