From ce49c7e06289165ebf420b5b8191a35ba4dcd16b Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 28 Apr 2019 16:54:59 +0100 Subject: [PATCH] Changed: improved favicon parsing --- Models/BookmarkItemModel.cs | 52 ++++++++++++++++++-------------- Properties/AssemblyInfo.cs | 2 +- Properties/Resources.Designer.cs | 2 +- Properties/Resources.resx | 2 +- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/Models/BookmarkItemModel.cs b/Models/BookmarkItemModel.cs index 8e78b6c..47d17b7 100644 --- a/Models/BookmarkItemModel.cs +++ b/Models/BookmarkItemModel.cs @@ -346,45 +346,53 @@ namespace bzit.bomg if (string.IsNullOrWhiteSpace(rs)) { - rs = parseTagValue_Attr(doc, "//link[@rel='shortcut icon']", "href", string.Empty); + //rs = parseTagValue_Attr(doc, "//link[@rel='shortcut icon']", "href", string.Empty); + rs = parseTagValue_Attr(doc, "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'shortcut icon']", "href", string.Empty); } if (string.IsNullOrWhiteSpace(rs)) { - rs = parseTagValue_Attr(doc, "//link[@rel='icon']", "href", string.Empty); - } + //rs = parseTagValue_Attr(doc, "//link[@rel='icon']", "href", string.Empty); + rs = parseTagValue_Attr(doc, "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'icon']", "href", string.Empty); + } - if (string.IsNullOrWhiteSpace(rs)) + if (string.IsNullOrWhiteSpace(rs)) { - rs = parseTagValue_Attr(doc, "//link[@rel='apple-touch-icon']", "href", string.Empty); - } + //rs = parseTagValue_Attr(doc, "//link[@rel='apple-touch-icon']", "href", string.Empty); + rs = parseTagValue_Attr(doc, "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'apple-touch-icon']", "href", string.Empty); + } - if (string.IsNullOrWhiteSpace(rs)) + if (string.IsNullOrWhiteSpace(rs)) { - rs = parseTagValue_Attr(doc, "//link[@rel='apple-touch-icon-precomposed']", "href", string.Empty); - } + //rs = parseTagValue_Attr(doc, "//link[@rel='apple-touch-icon-precomposed']", "href", string.Empty); + rs = parseTagValue_Attr(doc, "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'apple-touch-icon-precomposed']", "href", string.Empty); + } - if (string.IsNullOrWhiteSpace(rs)) + if (string.IsNullOrWhiteSpace(rs)) { - rs = parseTagValue_Attr(doc, "//meta[@property='og:image']", "content", string.Empty); - } + //rs = parseTagValue_Attr(doc, "//meta[@property='og:image']", "content", string.Empty); + rs = parseTagValue_Attr(doc, "//meta[translate(@property, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'og:image']", "content", string.Empty); + } - if (string.IsNullOrWhiteSpace(rs)) + if (string.IsNullOrWhiteSpace(rs)) { - rs = parseTagValue_Attr(doc, "//meta[@name='twitter:image']", "content", string.Empty); - } + //rs = parseTagValue_Attr(doc, "//meta[@name='twitter:image']", "content", string.Empty); + rs = parseTagValue_Attr(doc, "//meta[translate(@name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'twitter:image']", "content", string.Empty); + } - if (string.IsNullOrWhiteSpace(rs)) + if (string.IsNullOrWhiteSpace(rs)) { - rs = parseTagValue_Attr(doc, "//meta[@property='og:image']", "content", string.Empty); - } + //rs = parseTagValue_Attr(doc, "//meta[@property='og:image']", "content", string.Empty); + rs = parseTagValue_Attr(doc, "//meta[translate(@property, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'og:image']", "content", string.Empty); + } - if (string.IsNullOrWhiteSpace(rs)) + if (string.IsNullOrWhiteSpace(rs)) { - rs = parseTagValue_Attr(doc, "//meta[@itemprop='image']", "content", string.Empty); - } + //rs = parseTagValue_Attr(doc, "//meta[@itemprop='image']", "content", string.Empty); + rs = parseTagValue_Attr(doc, "//meta[translate(@itemprop, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'image']", "content", string.Empty); + } - return rs; + return rs; } } } \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 56a6f4f..62e3dab 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3.0.013")] +[assembly: AssemblyVersion("0.3.0.014")] [assembly: AssemblyFileVersion("0.1.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 4a5ce0b..3926832 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -89,7 +89,7 @@ namespace bzit.bomg.Properties { } /// - /// Looks up a localized string similar to 0.3.0.013 beta. + /// Looks up a localized string similar to 0.3.0.014 beta. /// internal static string app_version { get { diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 0e30a35..2b4e37b 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -128,7 +128,7 @@ Bookmark Manager - 0.3.0.013 beta + 0.3.0.014 beta ..\Resources\2\arrow-down-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a