Commit d132d9d7 authored by Eloy Durán's avatar Eloy Durán

Merge pull request #2497 from martincik/master

Sanitizing Plist UTF8 strings #2482
parents d90c9545 5873251f
......@@ -20,6 +20,10 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[laiso](https://github.com/laiso)
[#2489](https://github.com/CocoaPods/CocoaPods/pull/2489)
* Fixes an issue where `pod install` would crash during Plist building if any
pod has invalid UTF-8 characters in their title or description.
[Ladislav Martincik](https://github.com/martincik)
[#2482](https://github.com/CocoaPods/CocoaPods/issues/2482)
## 0.34.0.rc2
......
......@@ -36,8 +36,8 @@ module Pod
if (license = license_text(spec))
{
:Type => 'PSGroupSpecifier',
:Title => spec.name,
:FooterText => license,
:Title => sanitize_encoding(spec.name),
:FooterText => sanitize_encoding(license),
}
end
end
......@@ -45,18 +45,42 @@ module Pod
def header_hash
{
:Type => 'PSGroupSpecifier',
:Title => header_title,
:FooterText => header_text,
:Title => sanitize_encoding(header_title),
:FooterText => sanitize_encoding(header_text),
}
end
def footnote_hash
{
:Type => 'PSGroupSpecifier',
:Title => footnote_title,
:FooterText => footnote_text,
:Title => sanitize_encoding(footnote_title),
:FooterText => sanitize_encoding(footnote_text),
}
end
#-----------------------------------------------------------------------#
private
# !@group Private methods
# Returns the sanitized text with UTF-8 eliminating invalid characters if
# Ruby version >=1.9 else will return the text.
#
# @param [String] text
# the text we want to sanitize.
#
# @return [String] The sanitized text if Ruby >=1.9 else text.
#
def sanitize_encoding(text)
if RUBY_VERSION >= '1.9'
text.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '')
else
text
end
end
#-----------------------------------------------------------------------#
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment