Bug 1318857 - Unhide nsTSubstring_CharT::StripChars in nsTString_CharT. r?froydnj
MozReview-Commit-ID: CyQhH2y9lbm
--- a/intl/uconv/nsTextToSubURI.cpp
+++ b/intl/uconv/nsTextToSubURI.cpp
@@ -235,21 +235,20 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeU
}
// If there are any characters that are unsafe for URIs, reescape those.
if (mUnsafeChars.IsEmpty()) {
nsAdoptingString blacklist;
nsresult rv = mozilla::Preferences::GetString("network.IDN.blacklist_chars",
&blacklist);
if (NS_SUCCEEDED(rv)) {
- nsAString& chars = blacklist;
// we allow SPACE and IDEOGRAPHIC SPACE in this method
- chars.StripChars(u" \u3000");
- mUnsafeChars.AppendElements(static_cast<const char16_t*>(chars.Data()),
- chars.Length());
+ blacklist.StripChars(u" \u3000");
+ mUnsafeChars.AppendElements(static_cast<const char16_t*>(blacklist.Data()),
+ blacklist.Length());
} else {
NS_WARNING("Failed to get the 'network.IDN.blacklist_chars' preference");
}
// We check IsEmpty() intentionally here because an empty (or just spaces)
// pref value is likely a mistake/error of some sort.
if (mUnsafeChars.IsEmpty()) {
mUnsafeChars.AppendElements(sNetworkIDNBlacklistChars,
mozilla::ArrayLength(sNetworkIDNBlacklistChars));
--- a/xpcom/string/nsTString.h
+++ b/xpcom/string/nsTString.h
@@ -363,16 +363,19 @@ public:
/**
* These methods are used to remove all occurrences of the
* characters found in aSet from this string.
*
* @param aSet -- characters to be cut from this
*/
+#ifdef CharT_is_PRUnichar
+ using nsTSubstring_CharT::StripChars;
+#endif
void StripChars(const char* aSet);
/**
* This method strips whitespace throughout the string.
*/
void StripWhitespace();
--- a/xpcom/tests/gtest/TestStrings.cpp
+++ b/xpcom/tests/gtest/TestStrings.cpp
@@ -811,18 +811,17 @@ TEST(String, parse_string)
test_parse_string_helper0("", '_');
test_parse_string_helper0(" ", ' ');
test_parse_string_helper1(" foo", ' ', "foo");
test_parse_string_helper1(" foo", ' ', "foo");
}
static void test_strip_chars_helper(const char16_t* str, const char16_t* strip, const nsAString& result, uint32_t offset=0)
{
- nsAutoString tmp(str);
- nsAString& data = tmp;
+ nsAutoString data(str);
data.StripChars(strip, offset);
EXPECT_TRUE(data.Equals(result));
}
TEST(String, strip_chars)
{
test_strip_chars_helper(u"foo \r \nbar",
u" \n\r",