You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

references.go 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package references
  4. import (
  5. "bytes"
  6. "net/url"
  7. "regexp"
  8. "strconv"
  9. "strings"
  10. "sync"
  11. "code.gitea.io/gitea/modules/log"
  12. "code.gitea.io/gitea/modules/markup/mdstripper"
  13. "code.gitea.io/gitea/modules/setting"
  14. "github.com/yuin/goldmark/util"
  15. )
  16. var (
  17. // validNamePattern performs only the most basic validation for user or repository names
  18. // Repository name should contain only alphanumeric, dash ('-'), underscore ('_') and dot ('.') characters.
  19. validNamePattern = regexp.MustCompile(`^[a-z0-9_.-]+$`)
  20. // NOTE: All below regex matching do not perform any extra validation.
  21. // Thus a link is produced even if the linked entity does not exist.
  22. // While fast, this is also incorrect and lead to false positives.
  23. // TODO: fix invalid linking issue
  24. // mentionPattern matches all mentions in the form of "@user" or "@org/team"
  25. mentionPattern = regexp.MustCompile(`(?:\s|^|\(|\[)(@[0-9a-zA-Z-_]+|@[0-9a-zA-Z-_]+\/?[0-9a-zA-Z-_]+|@[0-9a-zA-Z-_][0-9a-zA-Z-_.]+\/?[0-9a-zA-Z-_.]+[0-9a-zA-Z-_])(?:\s|[:,;.?!]\s|[:,;.?!]?$|\)|\])`)
  26. // issueNumericPattern matches string that references to a numeric issue, e.g. #1287
  27. issueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\')([#!][0-9]+)(?:\s|$|\)|\]|[:;,.?!]\s|[:;,.?!]$)`)
  28. // issueAlphanumericPattern matches string that references to an alphanumeric issue, e.g. ABC-1234
  29. issueAlphanumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([A-Z]{1,10}-[1-9][0-9]*)(?:\s|$|\)|\]|:|\.(\s|$))`)
  30. // crossReferenceIssueNumericPattern matches string that references a numeric issue in a different repository
  31. // e.g. org/repo#12345
  32. crossReferenceIssueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-zA-Z-_\.]+/[0-9a-zA-Z-_\.]+[#!][0-9]+)(?:\s|$|\)|\]|[:;,.?!]\s|[:;,.?!]$)`)
  33. // crossReferenceCommitPattern matches a string that references a commit in a different repository
  34. // e.g. go-gitea/gitea@d8a994ef, go-gitea/gitea@d8a994ef243349f321568f9e36d5c3f444b99cae (7-40 characters)
  35. crossReferenceCommitPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-zA-Z-_\.]+)/([0-9a-zA-Z-_\.]+)@([0-9a-f]{7,40})(?:\s|$|\)|\]|[:;,.?!]\s|[:;,.?!]$)`)
  36. // spaceTrimmedPattern let's find the trailing space
  37. spaceTrimmedPattern = regexp.MustCompile(`(?:.*[0-9a-zA-Z-_])\s`)
  38. // timeLogPattern matches string for time tracking
  39. timeLogPattern = regexp.MustCompile(`(?:\s|^|\(|\[)(@([0-9]+([\.,][0-9]+)?(w|d|m|h))+)(?:\s|$|\)|\]|[:;,.?!]\s|[:;,.?!]$)`)
  40. issueCloseKeywordsPat, issueReopenKeywordsPat *regexp.Regexp
  41. issueKeywordsOnce sync.Once
  42. giteaHostInit sync.Once
  43. giteaHost string
  44. giteaIssuePullPattern *regexp.Regexp
  45. actionStrings = []string{
  46. "none",
  47. "closes",
  48. "reopens",
  49. "neutered",
  50. }
  51. )
  52. // XRefAction represents the kind of effect a cross reference has once is resolved
  53. type XRefAction int64
  54. const (
  55. // XRefActionNone means the cross-reference is simply a comment
  56. XRefActionNone XRefAction = iota // 0
  57. // XRefActionCloses means the cross-reference should close an issue if it is resolved
  58. XRefActionCloses // 1
  59. // XRefActionReopens means the cross-reference should reopen an issue if it is resolved
  60. XRefActionReopens // 2
  61. // XRefActionNeutered means the cross-reference will no longer affect the source
  62. XRefActionNeutered // 3
  63. )
  64. func (a XRefAction) String() string {
  65. return actionStrings[a]
  66. }
  67. // IssueReference contains an unverified cross-reference to a local issue or pull request
  68. type IssueReference struct {
  69. Index int64
  70. Owner string
  71. Name string
  72. Action XRefAction
  73. TimeLog string
  74. }
  75. // RenderizableReference contains an unverified cross-reference to with rendering information
  76. // The IsPull member means that a `!num` reference was used instead of `#num`.
  77. // This kind of reference is used to make pulls available when an external issue tracker
  78. // is used. Otherwise, `#` and `!` are completely interchangeable.
  79. type RenderizableReference struct {
  80. Issue string
  81. Owner string
  82. Name string
  83. CommitSha string
  84. IsPull bool
  85. RefLocation *RefSpan
  86. Action XRefAction
  87. ActionLocation *RefSpan
  88. }
  89. type rawReference struct {
  90. index int64
  91. owner string
  92. name string
  93. isPull bool
  94. action XRefAction
  95. issue string
  96. refLocation *RefSpan
  97. actionLocation *RefSpan
  98. timeLog string
  99. }
  100. func rawToIssueReferenceList(reflist []*rawReference) []IssueReference {
  101. refarr := make([]IssueReference, len(reflist))
  102. for i, r := range reflist {
  103. refarr[i] = IssueReference{
  104. Index: r.index,
  105. Owner: r.owner,
  106. Name: r.name,
  107. Action: r.action,
  108. TimeLog: r.timeLog,
  109. }
  110. }
  111. return refarr
  112. }
  113. // RefSpan is the position where the reference was found within the parsed text
  114. type RefSpan struct {
  115. Start int
  116. End int
  117. }
  118. func makeKeywordsPat(words []string) *regexp.Regexp {
  119. acceptedWords := parseKeywords(words)
  120. if len(acceptedWords) == 0 {
  121. // Never match
  122. return nil
  123. }
  124. return regexp.MustCompile(`(?i)(?:\s|^|\(|\[)(` + strings.Join(acceptedWords, `|`) + `):? $`)
  125. }
  126. func parseKeywords(words []string) []string {
  127. acceptedWords := make([]string, 0, 5)
  128. wordPat := regexp.MustCompile(`^[\pL]+$`)
  129. for _, word := range words {
  130. word = strings.ToLower(strings.TrimSpace(word))
  131. // Accept Unicode letter class runes (a-z, á, à, ä, )
  132. if wordPat.MatchString(word) {
  133. acceptedWords = append(acceptedWords, word)
  134. } else {
  135. log.Info("Invalid keyword: %s", word)
  136. }
  137. }
  138. return acceptedWords
  139. }
  140. func newKeywords() {
  141. issueKeywordsOnce.Do(func() {
  142. // Delay initialization until after the settings module is initialized
  143. doNewKeywords(setting.Repository.PullRequest.CloseKeywords, setting.Repository.PullRequest.ReopenKeywords)
  144. })
  145. }
  146. func doNewKeywords(close, reopen []string) {
  147. issueCloseKeywordsPat = makeKeywordsPat(close)
  148. issueReopenKeywordsPat = makeKeywordsPat(reopen)
  149. }
  150. // getGiteaHostName returns a normalized string with the local host name, with no scheme or port information
  151. func getGiteaHostName() string {
  152. giteaHostInit.Do(func() {
  153. if uapp, err := url.Parse(setting.AppURL); err == nil {
  154. giteaHost = strings.ToLower(uapp.Host)
  155. giteaIssuePullPattern = regexp.MustCompile(
  156. `(\s|^|\(|\[)` +
  157. regexp.QuoteMeta(strings.TrimSpace(setting.AppURL)) +
  158. `([0-9a-zA-Z-_\.]+/[0-9a-zA-Z-_\.]+)/` +
  159. `((?:issues)|(?:pulls))/([0-9]+)(?:\s|$|\)|\]|[:;,.?!]\s|[:;,.?!]$)`)
  160. } else {
  161. giteaHost = ""
  162. giteaIssuePullPattern = nil
  163. }
  164. })
  165. return giteaHost
  166. }
  167. // getGiteaIssuePullPattern
  168. func getGiteaIssuePullPattern() *regexp.Regexp {
  169. getGiteaHostName()
  170. return giteaIssuePullPattern
  171. }
  172. // FindAllMentionsMarkdown matches mention patterns in given content and
  173. // returns a list of found unvalidated user names **not including** the @ prefix.
  174. func FindAllMentionsMarkdown(content string) []string {
  175. bcontent, _ := mdstripper.StripMarkdownBytes([]byte(content))
  176. locations := FindAllMentionsBytes(bcontent)
  177. mentions := make([]string, len(locations))
  178. for i, val := range locations {
  179. mentions[i] = string(bcontent[val.Start+1 : val.End])
  180. }
  181. return mentions
  182. }
  183. // FindAllMentionsBytes matches mention patterns in given content
  184. // and returns a list of locations for the unvalidated user names, including the @ prefix.
  185. func FindAllMentionsBytes(content []byte) []RefSpan {
  186. // Sadly we can't use FindAllSubmatchIndex because our pattern checks for starting and
  187. // trailing spaces (\s@mention,\s), so if we get two consecutive references, the space
  188. // from the second reference will be "eaten" by the first one:
  189. // ...\s@mention1\s@mention2\s... --> ...`\s@mention1\s`, (not) `@mention2,\s...`
  190. ret := make([]RefSpan, 0, 5)
  191. pos := 0
  192. for {
  193. match := mentionPattern.FindSubmatchIndex(content[pos:])
  194. if match == nil {
  195. break
  196. }
  197. ret = append(ret, RefSpan{Start: match[2] + pos, End: match[3] + pos})
  198. notrail := spaceTrimmedPattern.FindSubmatchIndex(content[match[2]+pos : match[3]+pos])
  199. if notrail == nil {
  200. pos = match[3] + pos
  201. } else {
  202. pos = match[3] + pos + notrail[1] - notrail[3]
  203. }
  204. }
  205. return ret
  206. }
  207. // FindFirstMentionBytes matches the first mention in then given content
  208. // and returns the location of the unvalidated user name, including the @ prefix.
  209. func FindFirstMentionBytes(content []byte) (bool, RefSpan) {
  210. mention := mentionPattern.FindSubmatchIndex(content)
  211. if mention == nil {
  212. return false, RefSpan{}
  213. }
  214. return true, RefSpan{Start: mention[2], End: mention[3]}
  215. }
  216. // FindAllIssueReferencesMarkdown strips content from markdown markup
  217. // and returns a list of unvalidated references found in it.
  218. func FindAllIssueReferencesMarkdown(content string) []IssueReference {
  219. return rawToIssueReferenceList(findAllIssueReferencesMarkdown(content))
  220. }
  221. func findAllIssueReferencesMarkdown(content string) []*rawReference {
  222. bcontent, links := mdstripper.StripMarkdownBytes([]byte(content))
  223. return findAllIssueReferencesBytes(bcontent, links)
  224. }
  225. func convertFullHTMLReferencesToShortRefs(re *regexp.Regexp, contentBytes *[]byte) {
  226. // We will iterate through the content, rewrite and simplify full references.
  227. //
  228. // We want to transform something like:
  229. //
  230. // this is a https://ourgitea.com/git/owner/repo/issues/123456789, foo
  231. // https://ourgitea.com/git/owner/repo/pulls/123456789
  232. //
  233. // Into something like:
  234. //
  235. // this is a #123456789, foo
  236. // !123456789
  237. pos := 0
  238. for {
  239. // re looks for something like: (\s|^|\(|\[)https://ourgitea.com/git/(owner/repo)/(issues)/(123456789)(?:\s|$|\)|\]|[:;,.?!]\s|[:;,.?!]$)
  240. match := re.FindSubmatchIndex((*contentBytes)[pos:])
  241. if match == nil {
  242. break
  243. }
  244. // match is a bunch of indices into the content from pos onwards so
  245. // to simplify things let's just add pos to all of the indices in match
  246. for i := range match {
  247. match[i] += pos
  248. }
  249. // match[0]-match[1] is whole string
  250. // match[2]-match[3] is preamble
  251. // move the position to the end of the preamble
  252. pos = match[3]
  253. // match[4]-match[5] is owner/repo
  254. // now copy the owner/repo to end of the preamble
  255. endPos := pos + match[5] - match[4]
  256. copy((*contentBytes)[pos:endPos], (*contentBytes)[match[4]:match[5]])
  257. // move the current position to the end of the newly copied owner/repo
  258. pos = endPos
  259. // Now set the issue/pull marker:
  260. //
  261. // match[6]-match[7] == 'issues'
  262. (*contentBytes)[pos] = '#'
  263. if string((*contentBytes)[match[6]:match[7]]) == "pulls" {
  264. (*contentBytes)[pos] = '!'
  265. }
  266. pos++
  267. // Then add the issue/pull number
  268. //
  269. // match[8]-match[9] is the number
  270. endPos = pos + match[9] - match[8]
  271. copy((*contentBytes)[pos:endPos], (*contentBytes)[match[8]:match[9]])
  272. // Now copy what's left at the end of the string to the new end position
  273. copy((*contentBytes)[endPos:], (*contentBytes)[match[9]:])
  274. // now we reset the length
  275. // our new section has length endPos - match[3]
  276. // our old section has length match[9] - match[3]
  277. *contentBytes = (*contentBytes)[:len(*contentBytes)-match[9]+endPos]
  278. pos = endPos
  279. }
  280. }
  281. // FindAllIssueReferences returns a list of unvalidated references found in a string.
  282. func FindAllIssueReferences(content string) []IssueReference {
  283. // Need to convert fully qualified html references to local system to #/! short codes
  284. contentBytes := []byte(content)
  285. if re := getGiteaIssuePullPattern(); re != nil {
  286. convertFullHTMLReferencesToShortRefs(re, &contentBytes)
  287. } else {
  288. log.Debug("No GiteaIssuePullPattern pattern")
  289. }
  290. return rawToIssueReferenceList(findAllIssueReferencesBytes(contentBytes, []string{}))
  291. }
  292. // FindRenderizableReferenceNumeric returns the first unvalidated reference found in a string.
  293. func FindRenderizableReferenceNumeric(content string, prOnly bool) (bool, *RenderizableReference) {
  294. match := issueNumericPattern.FindStringSubmatchIndex(content)
  295. if match == nil {
  296. if match = crossReferenceIssueNumericPattern.FindStringSubmatchIndex(content); match == nil {
  297. return false, nil
  298. }
  299. }
  300. r := getCrossReference(util.StringToReadOnlyBytes(content), match[2], match[3], false, prOnly)
  301. if r == nil {
  302. return false, nil
  303. }
  304. return true, &RenderizableReference{
  305. Issue: r.issue,
  306. Owner: r.owner,
  307. Name: r.name,
  308. IsPull: r.isPull,
  309. RefLocation: r.refLocation,
  310. Action: r.action,
  311. ActionLocation: r.actionLocation,
  312. }
  313. }
  314. // FindRenderizableCommitCrossReference returns the first unvalidated commit cross reference found in a string.
  315. func FindRenderizableCommitCrossReference(content string) (bool, *RenderizableReference) {
  316. m := crossReferenceCommitPattern.FindStringSubmatchIndex(content)
  317. if len(m) < 8 {
  318. return false, nil
  319. }
  320. return true, &RenderizableReference{
  321. Owner: content[m[2]:m[3]],
  322. Name: content[m[4]:m[5]],
  323. CommitSha: content[m[6]:m[7]],
  324. RefLocation: &RefSpan{Start: m[2], End: m[7]},
  325. }
  326. }
  327. // FindRenderizableReferenceRegexp returns the first regexp unvalidated references found in a string.
  328. func FindRenderizableReferenceRegexp(content string, pattern *regexp.Regexp) (bool, *RenderizableReference) {
  329. match := pattern.FindStringSubmatchIndex(content)
  330. if len(match) < 4 {
  331. return false, nil
  332. }
  333. action, location := findActionKeywords([]byte(content), match[2])
  334. return true, &RenderizableReference{
  335. Issue: content[match[2]:match[3]],
  336. RefLocation: &RefSpan{Start: match[0], End: match[1]},
  337. Action: action,
  338. ActionLocation: location,
  339. IsPull: false,
  340. }
  341. }
  342. // FindRenderizableReferenceAlphanumeric returns the first alphanumeric unvalidated references found in a string.
  343. func FindRenderizableReferenceAlphanumeric(content string) (bool, *RenderizableReference) {
  344. match := issueAlphanumericPattern.FindStringSubmatchIndex(content)
  345. if match == nil {
  346. return false, nil
  347. }
  348. action, location := findActionKeywords([]byte(content), match[2])
  349. return true, &RenderizableReference{
  350. Issue: content[match[2]:match[3]],
  351. RefLocation: &RefSpan{Start: match[2], End: match[3]},
  352. Action: action,
  353. ActionLocation: location,
  354. IsPull: false,
  355. }
  356. }
  357. // FindAllIssueReferencesBytes returns a list of unvalidated references found in a byte slice.
  358. func findAllIssueReferencesBytes(content []byte, links []string) []*rawReference {
  359. ret := make([]*rawReference, 0, 10)
  360. pos := 0
  361. // Sadly we can't use FindAllSubmatchIndex because our pattern checks for starting and
  362. // trailing spaces (\s#ref,\s), so if we get two consecutive references, the space
  363. // from the second reference will be "eaten" by the first one:
  364. // ...\s#ref1\s#ref2\s... --> ...`\s#ref1\s`, (not) `#ref2,\s...`
  365. for {
  366. match := issueNumericPattern.FindSubmatchIndex(content[pos:])
  367. if match == nil {
  368. break
  369. }
  370. if ref := getCrossReference(content, match[2]+pos, match[3]+pos, false, false); ref != nil {
  371. ret = append(ret, ref)
  372. }
  373. notrail := spaceTrimmedPattern.FindSubmatchIndex(content[match[2]+pos : match[3]+pos])
  374. if notrail == nil {
  375. pos = match[3] + pos
  376. } else {
  377. pos = match[3] + pos + notrail[1] - notrail[3]
  378. }
  379. }
  380. pos = 0
  381. for {
  382. match := crossReferenceIssueNumericPattern.FindSubmatchIndex(content[pos:])
  383. if match == nil {
  384. break
  385. }
  386. if ref := getCrossReference(content, match[2]+pos, match[3]+pos, false, false); ref != nil {
  387. ret = append(ret, ref)
  388. }
  389. notrail := spaceTrimmedPattern.FindSubmatchIndex(content[match[2]+pos : match[3]+pos])
  390. if notrail == nil {
  391. pos = match[3] + pos
  392. } else {
  393. pos = match[3] + pos + notrail[1] - notrail[3]
  394. }
  395. }
  396. localhost := getGiteaHostName()
  397. for _, link := range links {
  398. if u, err := url.Parse(link); err == nil {
  399. // Note: we're not attempting to match the URL scheme (http/https)
  400. host := strings.ToLower(u.Host)
  401. if host != "" && host != localhost {
  402. continue
  403. }
  404. parts := strings.Split(u.EscapedPath(), "/")
  405. // /user/repo/issues/3
  406. if len(parts) != 5 || parts[0] != "" {
  407. continue
  408. }
  409. var sep string
  410. if parts[3] == "issues" {
  411. sep = "#"
  412. } else if parts[3] == "pulls" {
  413. sep = "!"
  414. } else {
  415. continue
  416. }
  417. // Note: closing/reopening keywords not supported with URLs
  418. bytes := []byte(parts[1] + "/" + parts[2] + sep + parts[4])
  419. if ref := getCrossReference(bytes, 0, len(bytes), true, false); ref != nil {
  420. ref.refLocation = nil
  421. ret = append(ret, ref)
  422. }
  423. }
  424. }
  425. if len(ret) == 0 {
  426. return ret
  427. }
  428. pos = 0
  429. for {
  430. match := timeLogPattern.FindSubmatchIndex(content[pos:])
  431. if match == nil {
  432. break
  433. }
  434. timeLogEntry := string(content[match[2]+pos+1 : match[3]+pos])
  435. var f *rawReference
  436. for _, ref := range ret {
  437. if ref.refLocation != nil && ref.refLocation.End < match[2]+pos && (f == nil || f.refLocation.End < ref.refLocation.End) {
  438. f = ref
  439. }
  440. }
  441. pos = match[1] + pos
  442. if f == nil {
  443. f = ret[0]
  444. }
  445. if len(f.timeLog) == 0 {
  446. f.timeLog = timeLogEntry
  447. }
  448. }
  449. return ret
  450. }
  451. func getCrossReference(content []byte, start, end int, fromLink, prOnly bool) *rawReference {
  452. sep := bytes.IndexAny(content[start:end], "#!")
  453. if sep < 0 {
  454. return nil
  455. }
  456. isPull := content[start+sep] == '!'
  457. if prOnly && !isPull {
  458. return nil
  459. }
  460. repo := string(content[start : start+sep])
  461. issue := string(content[start+sep+1 : end])
  462. index, err := strconv.ParseInt(issue, 10, 64)
  463. if err != nil {
  464. return nil
  465. }
  466. if repo == "" {
  467. if fromLink {
  468. // Markdown links must specify owner/repo
  469. return nil
  470. }
  471. action, location := findActionKeywords(content, start)
  472. return &rawReference{
  473. index: index,
  474. action: action,
  475. issue: issue,
  476. isPull: isPull,
  477. refLocation: &RefSpan{Start: start, End: end},
  478. actionLocation: location,
  479. }
  480. }
  481. parts := strings.Split(strings.ToLower(repo), "/")
  482. if len(parts) != 2 {
  483. return nil
  484. }
  485. owner, name := parts[0], parts[1]
  486. if !validNamePattern.MatchString(owner) || !validNamePattern.MatchString(name) {
  487. return nil
  488. }
  489. action, location := findActionKeywords(content, start)
  490. return &rawReference{
  491. index: index,
  492. owner: owner,
  493. name: name,
  494. action: action,
  495. issue: issue,
  496. isPull: isPull,
  497. refLocation: &RefSpan{Start: start, End: end},
  498. actionLocation: location,
  499. }
  500. }
  501. func findActionKeywords(content []byte, start int) (XRefAction, *RefSpan) {
  502. newKeywords()
  503. var m []int
  504. if issueCloseKeywordsPat != nil {
  505. m = issueCloseKeywordsPat.FindSubmatchIndex(content[:start])
  506. if m != nil {
  507. return XRefActionCloses, &RefSpan{Start: m[2], End: m[3]}
  508. }
  509. }
  510. if issueReopenKeywordsPat != nil {
  511. m = issueReopenKeywordsPat.FindSubmatchIndex(content[:start])
  512. if m != nil {
  513. return XRefActionReopens, &RefSpan{Start: m[2], End: m[3]}
  514. }
  515. }
  516. return XRefActionNone, nil
  517. }
  518. // IsXrefActionable returns true if the xref action is actionable (i.e. produces a result when resolved)
  519. func IsXrefActionable(ref *RenderizableReference, extTracker bool) bool {
  520. if extTracker {
  521. // External issues cannot be automatically closed
  522. return false
  523. }
  524. return ref.Action == XRefActionCloses || ref.Action == XRefActionReopens
  525. }