OSDN Git Service

#27313 ピリオドで終わるページが取得できない問題の暫定対応(警告メッセージの追加)
authorhoneplus <honeplus@users.osdn.me>
Sat, 11 Feb 2012 13:02:34 +0000 (13:02 +0000)
committerhoneplus <honeplus@users.osdn.me>
Sat, 11 Feb 2012 13:02:34 +0000 (13:02 +0000)
git-svn-id: http://svn.osdn.net/svnroot/wptscs/trunk@14 7cc79d57-4d93-40a1-83d5-ec7b38613dec

Wptscs/Logics/Translator.cs
Wptscs/Properties/Resources.Designer.cs
Wptscs/Properties/Resources.resx
Wptscs/Readme.txt
Wptscs/Websites/MediaWiki.cs

index 4570450..a133941 100644 (file)
@@ -447,7 +447,7 @@ namespace Honememo.Wptscs.Logics
         /// <item><description>正常にページが取得できた → <c>true</c>でページを設定、ログ出力無し</description></item>
         /// <item><description>404など想定内の例外でページが取得できなかった → <c>true</c>でページ無し、ログ出力無し</description></item>
         /// <item><description>想定外の例外でページが取得できなかった → <c>false</c>でページ無し、ログ出力有り
-        ///                    or <c>ApplicationException</c>で処理中断(アプリケーション設定のIgnoreErrorによる)。</description></item>
+        ///                    or <c>ApplicationException</c>で処理中断(アプリケーション設定のIgnoreErrorによる)。</description></item>
         /// </list>
         /// </remarks>
         private bool TryGetPageBody(string title, out Page page)
@@ -464,6 +464,12 @@ namespace Honememo.Wptscs.Logics
                 // ページ無しによる例外も正常終了
                 return true;
             }
+            catch (NotSupportedException)
+            {
+                // 末尾がピリオドで終わるページが処理できない既知の不具合への対応、警告メッセージを出す
+                this.Logger.AddResponse(Resources.LogMessageErrorPageName, title);
+                return false;
+            }
             catch (Exception e)
             {
                 // その他例外の場合、まずエラー情報を出力
index 23ac6b4..271d415 100644 (file)
@@ -190,6 +190,15 @@ namespace Honememo.Wptscs.Properties {
         }
         
         /// <summary>
+        ///   {0} は、現在のツールでは処理できないページ名です。 に類似しているローカライズされた文字列を検索します。
+        /// </summary>
+        internal static string LogMessageErrorPageName {
+            get {
+                return ResourceManager.GetString("LogMessageErrorPageName", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   要求したURLは {0} です。 に類似しているローカライズされた文字列を検索します。
         /// </summary>
         internal static string LogMessageErrorURL {
index 6ed1cb1..73a120a 100644 (file)
     <value>リトライ回数には0以上の数値を指定してください。</value>
     <comment>リトライ回数に不正な値を入れられた場合のメッセージ</comment>
   </data>
+  <data name="LogMessageErrorPageName" xml:space="preserve">
+    <value>{0} は、現在のツールでは処理できないページ名です。</value>
+    <comment>ページ名絡みの既知の不具合用の暫定メッセージ</comment>
+  </data>
 </root>
\ No newline at end of file
index 2fd30be..2e601d5 100644 (file)
@@ -153,6 +153,7 @@ Ver1.11  2012/02/xx メイン画面の言語プルダウンに存在しないコ
                     その他画面表示関係の不具合を修正。
                     変換後テキストの冒頭の元言語を{{Lang}}で囲むよう改善。
                     通信エラー時にリトライする仕組みを追加。
+                    未解決の既知の不具合について、警告等を表示するよう暫定対応。
                     トランスレータ周りのソース中心にリファクタリングを実施。
 
 
index 8bdd8e1..8373173 100644 (file)
@@ -441,23 +441,32 @@ namespace Honememo.Wptscs.Websites
         /// <param name="title">ページタイトル。</param>
         /// <returns>取得したページ。</returns>
         /// <exception cref="FileNotFoundException">ページが存在しない場合。</exception>
+        /// <exception cref="NotSupportedException">末尾がピリオドのページの場合(既知の不具合への対応)。</exception>
         /// <remarks>ページの取得に失敗した場合(通信エラーなど)は、その状況に応じた例外を投げる。</remarks>
         public override Page GetPage(string title)
         {
             // fileスキームの場合、記事名からファイルに使えない文字をエスケープ
             // ※ 仕組み的な処理はWebsite側に置きたいが、向こうではタイトルだけを抽出できないので
             string escapeTitle = title;
-            if (new Uri(this.Location).Scheme == "file")
+            if (new Uri(this.Location).IsFile)
             {
                 escapeTitle = FormUtils.ReplaceInvalidFileNameChars(title);
             }
 
+            // URIを生成
+            Uri uri = new Uri(new Uri(this.Location), StringUtils.FormatDollarVariable(this.ExportPath, escapeTitle));
+            if (uri.OriginalString.EndsWith("."))
+            {
+                // 末尾がピリオドのページが取得できない既知の不具合への暫定対応
+                // 対処方法が不明なため、せめて例外を投げて検知する
+                throw new NotSupportedException(title + " is not suppoted");
+            }
+
             // ページのXMLデータをMediaWikiサーバーから取得
             XmlDocument xml = new XmlDocument();
             try
             {
-                using (Stream reader = this.WebProxy.GetStream(
-                    new Uri(new Uri(this.Location), StringUtils.FormatDollarVariable(this.ExportPath, escapeTitle))))
+                using (Stream reader = this.WebProxy.GetStream(uri))
                 {
                     xml.Load(reader);
                 }