OSDN Git Service

BugTrack/2431 topicpath-title: ensure a.textContent == page
authorumorigu <umorigu@gmail.com>
Wed, 11 Apr 2018 12:57:13 +0000 (21:57 +0900)
committerumorigu <umorigu@gmail.com>
Wed, 11 Apr 2018 12:57:13 +0000 (21:57 +0900)
lib/html.php
skin/main.js

index 4ebe0b0..42b910f 100644 (file)
@@ -250,7 +250,11 @@ EOS;
        $plugin_prop = <<<EOS
 <input type="hidden" class="plugin-name" value="$h_plugin" />
 EOS;
-
+       // Page name
+       $h_page_name = htmlsc($page);
+       $page_name_data = <<<EOS
+<input type="hidden" class="page-name" value="$h_page_name" />
+EOS;
        // AutoTicketLink
        $filtered_ticket_link_sites = array();
        foreach ($ticket_link_sites as $s) {
@@ -287,6 +291,7 @@ EOS;
 <div id="pukiwiki-site-properties" style="display:none;">
 $site_props
 $plugin_prop
+$page_name_data
 $ticketlink_data
 $external_link_cushion_data
 $topicpath_data
index dab2f96..6c45340 100644 (file)
@@ -467,7 +467,13 @@ window.addEventListener && window.addEventListener('DOMContentLoaded', function(
     });
   }
   function makeTopicpathTitle() {
-    var topicpathE = document.querySelector('#pukiwiki-site-properties .topicpath-links');
+    if (!document.createDocumentFragment || !window.JSON) return;
+    var sitePropE = document.querySelector('#pukiwiki-site-properties');
+    if (!sitePropE) return;
+    var pageNameE = sitePropE.querySelector('.page-name');
+    if (!pageNameE || !pageNameE.value) return;
+    var pageName = pageNameE.value;
+    var topicpathE = sitePropE.querySelector('.topicpath-links');
     if (!topicpathE || !topicpathE.value) return;
     var topicpathLinks = JSON.parse(topicpathE.value);
     if (!topicpathLinks) return;
@@ -477,6 +483,7 @@ window.addEventListener && window.addEventListener('DOMContentLoaded', function(
     if (!aList || aList.length > 1) return;
     var a = titleH1.querySelector('a');
     if (!a) return;
+    if (a.textContent !== pageName) return;
     var fragment = document.createDocumentFragment();
     for (var i = 0, n = topicpathLinks.length; i < n; i++) {
       var path = topicpathLinks[i];