[Tween-svn] [1629] 不正なurlの頭に#が付いた発言で、重複範囲を指定した不正なエンティティがあるので対処。rev1626の対処はrevoke。

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2011年 10月 13日 (木) 19:56:33 JST


Revision: 1629
          http://sourceforge.jp/projects/tween/svn/view?view=rev&revision=1629
Author:   kiri_feather
Date:     2011-10-13 19:56:33 +0900 (Thu, 13 Oct 2011)

Log Message:
-----------
不正なurlの頭に#が付いた発言で、重複範囲を指定した不正なエンティティがあるので対処。rev1626の対処はrevoke。
画像キャッシュのログが邪魔なのでコメントアウト。

Revision Links:
--------------
    http://sourceforge.jp/projects/tween/svn/view?view=rev&revision=1626

Modified Paths:
--------------
    trunk/Tween/ImageDictionary.vb
    trunk/Tween/Twitter.vb


-------------- next part --------------
Modified: trunk/Tween/ImageDictionary.vb
===================================================================
--- trunk/Tween/ImageDictionary.vb	2011-10-12 16:23:20 UTC (rev 1628)
+++ trunk/Tween/ImageDictionary.vb	2011-10-13 10:56:33 UTC (rev 1629)
@@ -87,7 +87,7 @@
     Private Sub CacheRemoved(ByVal item As CacheEntryRemovedArguments)
         DirectCast(item.CacheItem.Value, Image).Dispose()
         removedCount += 1
-        System.Diagnostics.Debug.Print("cache delete")
+        'System.Diagnostics.Debug.Print("cache delete")
     End Sub
 
     Public Sub Add(ByVal item As System.Collections.Generic.KeyValuePair(Of String, Image)) Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of String, Image)).Add

Modified: trunk/Tween/Twitter.vb
===================================================================
--- trunk/Tween/Twitter.vb	2011-10-12 16:23:20 UTC (rev 1628)
+++ trunk/Tween/Twitter.vb	2011-10-13 10:56:33 UTC (rev 1629)
@@ -3170,7 +3170,6 @@
             'URL
             If entities.Urls IsNot Nothing Then
                 For Each ent In entities.Urls
-                    Array.Sort(ent.Indices)
                     If String.IsNullOrEmpty(ent.DisplayUrl) Then
                         etInfo.Add(ent.Indices(0),
                                    New EntityInfo With {.StartIndex = ent.Indices(0),
@@ -3191,7 +3190,6 @@
             End If
             If entities.Hashtags IsNot Nothing Then
                 For Each ent In entities.Hashtags
-                    Array.Sort(ent.Indices)
                     Dim hash As String = Text.Substring(ent.Indices(0), ent.Indices(1) - ent.Indices(0))
                     etInfo.Add(ent.Indices(0),
                                New EntityInfo With {.StartIndex = ent.Indices(0),
@@ -3205,7 +3203,6 @@
             End If
             If entities.UserMentions IsNot Nothing Then
                 For Each ent In entities.UserMentions
-                    Array.Sort(ent.Indices)
                     Dim screenName As String = Text.Substring(ent.Indices(0) + 1, ent.Indices(1) - ent.Indices(0) - 1)
                     etInfo.Add(ent.Indices(0) + 1,
                                New EntityInfo With {.StartIndex = ent.Indices(0) + 1,
@@ -3217,7 +3214,6 @@
             End If
             If entities.Media IsNot Nothing Then
                 For Each ent In entities.Media
-                    Array.Sort(ent.Indices)
                     If ent.Type = "photo" Then
                         etInfo.Add(ent.Indices(0),
                                    New EntityInfo With {.StartIndex = ent.Indices(0),
@@ -3230,13 +3226,20 @@
                 Next
             End If
             If etInfo.Count > 0 Then
-                Dim idx As Integer = 0
-                ret = ""
-                For Each et In etInfo
-                    ret += Text.Substring(idx, et.Key - idx) + et.Value.Html
-                    idx = et.Value.EndIndex
-                Next
-                ret += Text.Substring(idx)
+                Try
+                    Dim idx As Integer = 0
+                    ret = ""
+                    For Each et In etInfo
+                        ret += Text.Substring(idx, et.Key - idx) + et.Value.Html
+                        idx = et.Value.EndIndex
+                    Next
+                    ret += Text.Substring(idx)
+                Catch ex As ArgumentOutOfRangeException
+                    'Twitterのバグで不正なエンティティ(Index指定範囲が重なっている)が返ってくる場合の対応
+                    ret = Text
+                    entities = Nothing
+                    If media IsNot Nothing Then media.Clear()
+                End Try
             End If
         End If
 



Tween-svn メーリングリストの案内
アーカイブの一覧に戻る