Skip to content
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

Force encoding to UTF-8 when normalizing comp name #182

Merged
merged 1 commit into from
Dec 5, 2014
Merged

Conversation

gfontenot
Copy link
Member

This fixes a crash on non en_US.UTF-8 systems

Fixes #171

@keith
Copy link
Contributor

keith commented Oct 16, 2014

👍

@gabebw
Copy link
Contributor

gabebw commented Oct 17, 2014

👍

@gabebw
Copy link
Contributor

gabebw commented Oct 17, 2014

Add a test?

@gfontenot
Copy link
Member Author

@gabebw oh yeah right tests. brb.

@gfontenot gfontenot force-pushed the gf-fix-utf8 branch 4 times, most recently from c6f5c75 to 2ecf886 Compare December 5, 2014 15:53
@gfontenot
Copy link
Member Author

@gabebw test added. Mind taking another gander?

@@ -83,7 +83,7 @@ def test_target_groups
private

def normalized_company_name
company.gsub(/[^0-9a-z]/i, '').downcase
company.force_encoding('utf-8').gsub(/[^0-9a-z]/i, '').downcase
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nitpick, but what if we capitalize UTF-8? I almost never see it written lowercase, and if Ruby doesn't care I'd prefer uppercase.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@gfontenot gfontenot force-pushed the gf-fix-utf8 branch 2 times, most recently from da158d6 to 409a832 Compare December 5, 2014 16:02
@gabebw
Copy link
Contributor

gabebw commented Dec 5, 2014

The tests pass on my machine as well, even with $LANG unset. Looks good to me.

@gabebw
Copy link
Contributor

gabebw commented Dec 5, 2014

How about changing the commit message: "Force UTF-8 when normalizing company name"? "comp name" reads oddly to me.

This fixes a crash on non `en_US.UTF-8` systems, or when `LANG` isn't
set properly.
@gfontenot gfontenot merged commit e90a857 into master Dec 5, 2014
@gfontenot gfontenot deleted the gf-fix-utf8 branch December 5, 2014 16:09
@gfontenot
Copy link
Member Author

Done. Thanks, @gabebw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using UTF-8 characters crashes project generation
3 participants