[banshee] Trim filename dots and spaces (BGO #588350)
- From: Gabriel Burt <gburt src gnome org>
- To: svn-commits-list gnome org
- Subject: [banshee] Trim filename dots and spaces (BGO #588350)
- Date: Mon, 13 Jul 2009 17:27:20 +0000 (UTC)
commit 3ba5dfc304c27ed36f729fed20743e17307889b6
Author: Nils Naumann <nau gmx net>
Date: Sun Jul 12 21:35:42 2009 +0200
Trim filename dots and spaces (BGO #588350)
Signed-off-by: Gabriel Burt <gabriel burt gmail com>
src/Libraries/Hyena/Hyena/StringUtil.cs | 9 +++++----
src/Libraries/Hyena/Hyena/Tests/StringUtilTests.cs | 4 ++--
2 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/Libraries/Hyena/Hyena/StringUtil.cs b/src/Libraries/Hyena/Hyena/StringUtil.cs
index 5386083..d48f73d 100644
--- a/src/Libraries/Hyena/Hyena/StringUtil.cs
+++ b/src/Libraries/Hyena/Hyena/StringUtil.cs
@@ -256,16 +256,19 @@ namespace Hyena
if (orig == null) { return null; }
return culture_compare_info.GetSortKey (orig, CompareOptions.IgnoreCase).KeyData;
}
-
+
+ private static readonly char[] escape_path_trim_chars = new char[] {'.', '\x20'};
public static string EscapeFilename (string input)
{
if (input == null)
return "";
+ // Remove leading and trailing dots and spaces.
+ input = input.Trim (escape_path_trim_chars);
+
return invalid_path_regex.Replace (input, "_");
}
- private static readonly char[] escape_path_trim_chars = new char[] {'.', '\x20'};
public static string EscapePath (string input)
{
if (input == null)
@@ -280,8 +283,6 @@ namespace Hyena
foreach (string name in input.Split (Path.DirectorySeparatorChar)) {
// Escape the directory or the file name.
string escaped = EscapeFilename (name);
- // Remove leading and trailing dots and spaces.
- escaped = escaped.Trim (escape_path_trim_chars);
// Skip empty names.
if (escaped.Length > 0) {
builder.Append (escaped);
diff --git a/src/Libraries/Hyena/Hyena/Tests/StringUtilTests.cs b/src/Libraries/Hyena/Hyena/Tests/StringUtilTests.cs
index bde07d0..bf567fe 100644
--- a/src/Libraries/Hyena/Hyena/Tests/StringUtilTests.cs
+++ b/src/Libraries/Hyena/Hyena/Tests/StringUtilTests.cs
@@ -269,8 +269,8 @@ href=http://lkjdflkjdflkjj>baz foo< /a> bar"));
{
AssertProduces (null, "");
AssertProduces ("", "");
- AssertProduces (" ", " ");
- AssertProduces (" ", " ");
+ AssertProduces (" ", "");
+ AssertProduces (" ", "");
}
[Test]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]