From 8004503d4ff7d274c06099743e09519ed2eab716 Mon Sep 17 00:00:00 2001 From: honeplus Date: Sat, 11 Feb 2012 13:02:34 +0000 Subject: [PATCH] =?utf8?q?#27313=20=E3=83=94=E3=83=AA=E3=82=AA=E3=83=89?= =?utf8?q?=E3=81=A7=E7=B5=82=E3=82=8F=E3=82=8B=E3=83=9A=E3=83=BC=E3=82=B8?= =?utf8?q?=E3=81=8C=E5=8F=96=E5=BE=97=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84?= =?utf8?q?=E5=95=8F=E9=A1=8C=E3=81=AE=E6=9A=AB=E5=AE=9A=E5=AF=BE=E5=BF=9C?= =?utf8?q?=EF=BC=88=E8=AD=A6=E5=91=8A=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC?= =?utf8?q?=E3=82=B8=E3=81=AE=E8=BF=BD=E5=8A=A0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.osdn.net/svnroot/wptscs/trunk@14 7cc79d57-4d93-40a1-83d5-ec7b38613dec --- Wptscs/Logics/Translator.cs | 8 +++++++- Wptscs/Properties/Resources.Designer.cs | 9 +++++++++ Wptscs/Properties/Resources.resx | 4 ++++ Wptscs/Readme.txt | 1 + Wptscs/Websites/MediaWiki.cs | 15 ++++++++++++--- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Wptscs/Logics/Translator.cs b/Wptscs/Logics/Translator.cs index 4570450..a133941 100644 --- a/Wptscs/Logics/Translator.cs +++ b/Wptscs/Logics/Translator.cs @@ -447,7 +447,7 @@ namespace Honememo.Wptscs.Logics /// 正常にページが取得できた → trueでページを設定、ログ出力無し /// 404など想定内の例外でページが取得できなかった → trueでページ無し、ログ出力無し /// 想定外の例外でページが取得できなかった → falseでページ無し、ログ出力有り - /// or ApplicationExceptionで処理中断(アプリケーション設定のIgnoreErrorによる)。 + /// or ApplicationExceptionで処理中断(アプリケーション設定のIgnoreError等による)。 /// /// 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) { // その他例外の場合、まずエラー情報を出力 diff --git a/Wptscs/Properties/Resources.Designer.cs b/Wptscs/Properties/Resources.Designer.cs index 23ac6b4..271d415 100644 --- a/Wptscs/Properties/Resources.Designer.cs +++ b/Wptscs/Properties/Resources.Designer.cs @@ -190,6 +190,15 @@ namespace Honememo.Wptscs.Properties { } /// + /// {0} は、現在のツールでは処理できないページ名です。 に類似しているローカライズされた文字列を検索します。 + /// + internal static string LogMessageErrorPageName { + get { + return ResourceManager.GetString("LogMessageErrorPageName", resourceCulture); + } + } + + /// /// 要求したURLは {0} です。 に類似しているローカライズされた文字列を検索します。 /// internal static string LogMessageErrorURL { diff --git a/Wptscs/Properties/Resources.resx b/Wptscs/Properties/Resources.resx index 6ed1cb1..73a120a 100644 --- a/Wptscs/Properties/Resources.resx +++ b/Wptscs/Properties/Resources.resx @@ -347,4 +347,8 @@ リトライ回数には0以上の数値を指定してください。 リトライ回数に不正な値を入れられた場合のメッセージ + + {0} は、現在のツールでは処理できないページ名です。 + ページ名絡みの既知の不具合用の暫定メッセージ + \ No newline at end of file diff --git a/Wptscs/Readme.txt b/Wptscs/Readme.txt index 2fd30be..2e601d5 100644 --- a/Wptscs/Readme.txt +++ b/Wptscs/Readme.txt @@ -153,6 +153,7 @@ Ver1.11 2012/02/xx メイン画面の言語プルダウンに存在しないコ その他画面表示関係の不具合を修正。 変換後テキストの冒頭の元言語を{{Lang}}で囲むよう改善。 通信エラー時にリトライする仕組みを追加。 + 未解決の既知の不具合について、警告等を表示するよう暫定対応。 トランスレータ周りのソース中心にリファクタリングを実施。 diff --git a/Wptscs/Websites/MediaWiki.cs b/Wptscs/Websites/MediaWiki.cs index 8bdd8e1..8373173 100644 --- a/Wptscs/Websites/MediaWiki.cs +++ b/Wptscs/Websites/MediaWiki.cs @@ -441,23 +441,32 @@ namespace Honememo.Wptscs.Websites /// ページタイトル。 /// 取得したページ。 /// ページが存在しない場合。 + /// 末尾がピリオドのページの場合(既知の不具合への対応)。 /// ページの取得に失敗した場合(通信エラーなど)は、その状況に応じた例外を投げる。 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); } -- 2.11.0