diff --git a/properties.go b/properties.go index 2e4c8a2..bdfdd4b 100644 --- a/properties.go +++ b/properties.go @@ -833,6 +833,8 @@ func escape(r rune, special string) string { return "\\r" case '\t': return "\\t" + case '\\': + return "\\\\" default: if strings.ContainsRune(special, r) { return "\\" + string(r) diff --git a/properties_test.go b/properties_test.go index 9ffa2e0..619da63 100644 --- a/properties_test.go +++ b/properties_test.go @@ -152,12 +152,14 @@ var writeTests = []struct { {"key = value \\\n continued", "key = value continued\n", "ISO-8859-1"}, {"key⌘ = value", "key\\u2318 = value\n", "ISO-8859-1"}, {"ke\\ \\:y = value", "ke\\ \\:y = value\n", "ISO-8859-1"}, + {"ke\\\\y = val\\\\ue", "ke\\\\y = val\\\\ue\n", "ISO-8859-1"}, // UTF-8 tests {"key = value", "key = value\n", "UTF-8"}, {"key = value \\\n continued", "key = value continued\n", "UTF-8"}, {"key⌘ = value⌘", "key⌘ = value⌘\n", "UTF-8"}, {"ke\\ \\:y = value", "ke\\ \\:y = value\n", "UTF-8"}, + {"ke\\\\y = val\\\\ue", "ke\\\\y = val\\\\ue\n", "UTF-8"}, } // ---------------------------------------------------------------------------- @@ -330,6 +332,7 @@ var stringTests = []struct { }{ // valid values {"key = abc", "key", "def", "abc"}, + {"key = ab\\\\c", "key", "def", "ab\\c"}, // non existent key {"key = abc", "key2", "def", "def"}, @@ -346,6 +349,7 @@ var keysTests = []struct { {"key = abc\nkey2=def", []string{"key", "key2"}}, {"key2 = abc\nkey=def", []string{"key2", "key"}}, {"key = abc\nkey=def", []string{"key"}}, + {"key\\\\with\\\\backslashes = abc", []string{"key\\with\\backslashes"}}, } // ----------------------------------------------------------------------------