• R/O
  • HTTP
  • SSH
  • HTTPS

pukiwiki: Commit


Commit MetaInfo

Revision95306d1416055e444cb081f352f8e34ae3eaf855 (tree)
Time2017-04-02 15:59:51
Authorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

AutoTicketLink: Support hyphen and dot in key

Change Summary

Incremental Difference

--- a/lib/html.php
+++ b/lib/html.php
@@ -210,6 +210,9 @@ function get_html_scripting_data()
210210 };
211211 $text = '';
212212 foreach ($ticket_link_sites as $s) {
213+ if (!preg_match('/^([a-zA-Z0-9]+)([\.\-][a-zA-Z0-9]+)*$/', $s['key'])) {
214+ continue;
215+ }
213216 $site_info_json = htmlsc(json_encode($s, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
214217 $text .= <<<EOS
215218 <span class="pukiwiki-ticketlink-site" data-site="$site_info_json"></span>
--- a/skin/ticketlink.js
+++ b/skin/ticketlink.js
@@ -18,16 +18,21 @@ if (window.addEventListener) {
1818 }
1919 return '';
2020 }
21+ function regexEscape(key) {
22+ return key.replace(/[\-\.]/g, function (m) {
23+ return '\\' + m;
24+ });
25+ }
2126 function setupSites(siteList) {
2227 for (var i = 0, length = siteList.length; i < length; i++) {
2328 var site = siteList[i];
2429 var reText = '';
2530 switch (site.type) {
2631 case 'jira':
27- reText = '(' + site.key + '):' + '([A-Z][A-Z0-9]+-\\d+)';
32+ reText = '(' + regexEscape(site.key) + '):' + '([A-Z][A-Z0-9]+-\\d+)';
2833 break;
2934 case 'redmine':
30- reText = '(' + site.key + '):' + '(\\d+)';
35+ reText = '(' + regexEscape(site.key) + '):' + '(\\d+)';
3136 break;
3237 default:
3338 continue;
Show on old repository browser