escapeLikePattern escapes the three characters that carry meaning inside a LIKE pattern, for use with an explicit `ESCAPE '\'` clause. Without this the cascade's own search term is interpreted as a pattern, and a document TITLE decides how (BUG-2798, plus the rest of the class it was an instance of
(title string)
| 622 | // matches them all. It is a superset by construction, and the rewriter's own |
| 623 | // matcher is the authority on which rows actually link the title. |
| 624 | func titleLinkLikePattern(title string) string { |
| 625 | parts := strings.Split(links.EscapeWikiTitle(title), `\`) |
| 626 | for i := range parts { |
| 627 | parts[i] = escapeLikePattern(parts[i]) |
| 628 | } |
| 629 | return "%[[" + strings.Join(parts, "%") + "]]%" |
| 630 | } |
| 631 | |
| 632 | func escapeLikePattern(s string) string { |
| 633 | r := strings.NewReplacer(`\`, `\\`, `%`, `\%`, `_`, `\_`) |
no test coverage detected