banshee r4611 - in trunk/banshee: . src/Extensions/Banshee.Podcasting/Banshee.Podcasting src/Libraries/Hyena/Hyena src/Libraries/Hyena/Hyena/Tests src/Libraries/Migo/Migo.Syndication
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4611 - in trunk/banshee: . src/Extensions/Banshee.Podcasting/Banshee.Podcasting src/Libraries/Hyena/Hyena src/Libraries/Hyena/Hyena/Tests src/Libraries/Migo/Migo.Syndication
- Date: Wed, 24 Sep 2008 22:00:20 +0000 (UTC)
Author: gburt
Date: Wed Sep 24 22:00:20 2008
New Revision: 4611
URL: http://svn.gnome.org/viewvc/banshee?rev=4611&view=rev
Log:
2008-09-24 Gabriel Burt <gabriel burt gmail com>
* src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs:
Run UPDATE queries against CoreTracks and PodcastItems to remove any
newlines.
* src/Libraries/Hyena/Hyena/Tests/StringUtilTests.cs:
* src/Libraries/Hyena/Hyena/StringUtil.cs: Add and test new method for
removing all newlines from a string.
* src/Libraries/Migo/Migo.Syndication/Feed.cs: Remove newlines from title
and description when setting them (BGO #550008).
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
trunk/banshee/src/Libraries/Hyena/Hyena/StringUtil.cs
trunk/banshee/src/Libraries/Hyena/Hyena/Tests/StringUtilTests.cs
trunk/banshee/src/Libraries/Migo/Migo.Syndication/Feed.cs
Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs Wed Sep 24 22:00:20 2008
@@ -189,6 +189,21 @@
DatabaseConfigurationClient.Client.Set<int> ("Podcast", "Version", 3);
}
+
+ if (DatabaseConfigurationClient.Client.Get<int> ("Podcast", "Version", 0) < 4) {
+ ReplaceNewlines ("CoreTracks", "Title");
+ ReplaceNewlines ("CoreTracks", "TitleLowered");
+ ReplaceNewlines ("PodcastItems", "Title");
+ ReplaceNewlines ("PodcastItems", "Description");
+ DatabaseConfigurationClient.Client.Set<int> ("Podcast", "Version", 4);
+ }
+ }
+
+ private void ReplaceNewlines (string table, string column)
+ {
+ string cmd = String.Format ("UPDATE {0} SET {1}=replace({1}, ?, ?)", table, column);
+ ServiceManager.DbConnection.Execute (cmd, "\n", String.Empty);
+ ServiceManager.DbConnection.Execute (cmd, "\r\n", String.Empty);
}
public void Initialize ()
Modified: trunk/banshee/src/Libraries/Hyena/Hyena/StringUtil.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena/StringUtil.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena/StringUtil.cs Wed Sep 24 22:00:20 2008
@@ -118,6 +118,14 @@
return builder.ToString ();
}
+ public static string RemoveNewlines (string input)
+ {
+ if (input != null) {
+ return input.Replace ("\r\n", String.Empty).Replace ("\n", String.Empty);
+ }
+ return null;
+ }
+
public static string DoubleToTenthsPrecision (double num)
{
return DoubleToTenthsPrecision (num, false);
Modified: trunk/banshee/src/Libraries/Hyena/Hyena/Tests/StringUtilTests.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena/Tests/StringUtilTests.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena/Tests/StringUtilTests.cs Wed Sep 24 22:00:20 2008
@@ -119,6 +119,20 @@
Assert.AreEqual (2, StringUtil.DoubleToPluralInt (1.8));
Assert.AreEqual (22, StringUtil.DoubleToPluralInt (21.3));
}
+
+ [Test]
+ public void RemovesNewlines ()
+ {
+ Assert.AreEqual ("foobar", StringUtil.RemoveNewlines (@"foo
+bar"));
+ Assert.AreEqual ("foobar baz", StringUtil.RemoveNewlines (@"foo
+bar
+baz"));
+ Assert.AreEqual ("haswindows newline andunix", StringUtil.RemoveNewlines (@"has
+windows
+ newline
+andunix"));
+ }
}
}
Modified: trunk/banshee/src/Libraries/Migo/Migo.Syndication/Feed.cs
==============================================================================
--- trunk/banshee/src/Libraries/Migo/Migo.Syndication/Feed.cs (original)
+++ trunk/banshee/src/Libraries/Migo/Migo.Syndication/Feed.cs Wed Sep 24 22:00:20 2008
@@ -147,13 +147,13 @@
[DatabaseColumn]
public string Title {
get { return title ?? Catalog.GetString ("Unknown Podcast"); }
- set { title = value; }
+ set { title = StringUtil.RemoveNewlines (value); }
}
[DatabaseColumn]
public string Description {
get { return description; }
- set { description = value; }
+ set { description = StringUtil.RemoveNewlines (value); }
}
[DatabaseColumn]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]