[banshee/stable-2.6] Revert "Migo: Fixed parsing RSSs with BOM (bgo#727432)"



commit 4c70306a6f807c77d255ef5c0f26f07646d25e3b
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Fri Jul 3 15:43:21 2015 +0200

    Revert "Migo: Fixed parsing RSSs with BOM (bgo#727432)"
    
    This reverts commit de4d32035e735f694f0537d4fd221e21e607b6a1.
    
    There were some problems with this patch:
    
    a) When improving the version that Marcin posted in bugzilla,
    in order to not hardcode UTF8 encoding, I incorrectly placed
    this logic inside an if block like this:
    
     if (s.StartsWith("<?xml")) {
    
    b) But, given that the logic to remove the bom also asks for
    
     if (s.StartsWith(bom)) {
    
    You would think that the logic added to fix this bug
    would simply not work (because the condition that made
    the code flow enter into the parent block would make
    the second condition FALSE).
    
    c) However, surprisingly enough, the bom from the podcast
    example in bugzilla [0] is parsed as UTF8 and UTF8's
    ByteOrderMark's length is 1, and Mono returns true for
    both of the conditions above, even if bom is obviously
    not "<" (the first character of the "<?xml" string to
    check if the content is XML).
    
    I still don't understand how can this be possible, but
    the consequence of it is that the content is stripped
    from its first character, so all XML feeds received
    that started with "<?xml" were converted to a string
    starting with "?xml", which clearly resulted in a
    parsing error.
    
    Not sure if this is a Mono bug, and not sure this is
    fixed in newer versions, but with the version I'm using
    now (3.2.8) I cannot reproduce bug 727432, and this is
    a very widely used version of Mono (it comes with
    Ubuntu 14.04 LTS, 14.10, and 15.04). So I'm reverting
    the fix for this (until we figure out a better fix, and
    the exact environment to reproduce it), otherwise many
    more podcasts would be broken.
    
    [0] http://podcast.dr.dk/p1/rssfeed/orientering.xml

 src/Libraries/Migo/Migo.Net/AsyncWebClient.cs |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)
---
diff --git a/src/Libraries/Migo/Migo.Net/AsyncWebClient.cs b/src/Libraries/Migo/Migo.Net/AsyncWebClient.cs
index 6b05093..18ac5ff 100644
--- a/src/Libraries/Migo/Migo.Net/AsyncWebClient.cs
+++ b/src/Libraries/Migo/Migo.Net/AsyncWebClient.cs
@@ -735,19 +735,12 @@ namespace Migo.Net
                                 Match match = encoding_regexp.Match (s);
                                 if (match.Success && match.Groups.Count > 0) {
                                     string encodingStr = match.Groups[1].Value;
-
-                                    Encoding enc = Encoding;
                                     try {
-                                        enc = Encoding.GetEncoding (encodingStr);
+                                        Encoding enc = Encoding.GetEncoding (encodingStr);
                                         if (!enc.Equals (Encoding)) {
                                             s = enc.GetString (resultPtr);
                                         }
                                     } catch (ArgumentException) {}
-
-                                    string bom = enc.GetString (enc.GetPreamble ());
-                                    if (s.StartsWith (bom)) {
-                                        s = s.Remove (0, bom.Length);
-                                    }
                                 }
                             }
                         } catch (Exception ex) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]