• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョンf17bc09a8167e9f11cb2250e74c1651c6c4ee67a (tree)
日時2017-10-28 00:50:11
作者umorigu <umorigu@gmai...>
コミッターumorigu

ログメッセージ

BugTrack/2283 ls2 plugin: Improve include loop handling

* Fix infinite loop on 'include' and no-'title' condition
* Trace including tree on each page

変更サマリ

差分

--- a/plugin/ls2.inc.php
+++ b/plugin/ls2.inc.php
@@ -117,12 +117,13 @@ function plugin_ls2_show_lists($prefix, & $params)
117117 }
118118 }
119119
120-function plugin_ls2_get_headings($page, & $params, $level, $include = FALSE)
120+function plugin_ls2_get_headings($page, & $params, $level, $include = FALSE,
121+ &$read_pages = array())
121122 {
122123 static $_ls2_anchor = 0;
123124
124125 // ページが未表示のとき
125- $is_done = (isset($params["page_$page"]) && $params["page_$page"] > 0);
126+ $is_done = isset($read_pages[$page]);
126127 if (! $is_done) $params["page_$page"] = ++$_ls2_anchor;
127128
128129 $s_page = htmlsc($page);
@@ -132,7 +133,7 @@ function plugin_ls2_get_headings($page, & $params, $level, $include = FALSE)
132133 plugin_ls2_list_push($params, $level);
133134 $ret = $include ? '<li>include ' : '<li>';
134135
135- if ($params['title'] && $is_done) {
136+ if ($is_done) {
136137 $ret .= '<a href="' . $href . '" title="' . $title . '">' . $s_page . '</a> ';
137138 $ret .= '<a href="#list_' . $params["page_$page"] . '"><sup>&uarr;</sup></a>';
138139 array_push($params['result'], $ret);
@@ -162,7 +163,11 @@ function plugin_ls2_get_headings($page, & $params, $level, $include = FALSE)
162163 preg_match('/^#include\((.+)\)/', $line, $matches) &&
163164 is_page($matches[1]))
164165 {
165- plugin_ls2_get_headings($matches[1], $params, $level + 1, TRUE);
166+ $read_pages[$page] = 1;
167+ $sub_page = $matches[1];
168+ if (!isset($read_pages[$sub_page])) {
169+ plugin_ls2_get_headings($sub_page, $params, $level + 1, TRUE, $read_pages);
170+ }
166171 }
167172 }
168173 }