/// <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)
// ページ無しによる例外も正常終了
return true;
}
+ catch (NotSupportedException)
+ {
+ // 末尾がピリオドで終わるページが処理できない既知の不具合への対応、警告メッセージを出す
+ this.Logger.AddResponse(Resources.LogMessageErrorPageName, title);
+ return false;
+ }
catch (Exception e)
{
// その他例外の場合、まずエラー情報を出力
}
/// <summary>
+ /// {0} は、現在のツールでは処理できないページ名です。 に類似しているローカライズされた文字列を検索します。
+ /// </summary>
+ internal static string LogMessageErrorPageName {
+ get {
+ return ResourceManager.GetString("LogMessageErrorPageName", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// 要求したURLは {0} です。 に類似しているローカライズされた文字列を検索します。
/// </summary>
internal static string LogMessageErrorURL {
<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
/// <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);
}