Fix bug with non-latin languages.

- Fix: When $wgCapitalLinks was true, the extension would not work with non-latin languages.

Closes #7.
This commit is contained in:
Daniel Kraus
2017-08-29 06:08:30 +02:00
parent 0d8d2bfbb2
commit 1ba5a7b799
3 changed files with 4 additions and 2 deletions

View File

@ -31,6 +31,7 @@ Contributors
- Daniel Kraus (@bovender), main developer
- Ulrich Strauss (@c0nnex), namespaces
- Brent Laabs (@labster), code review and bug fixes
- @tetsuya-zama, bug fix
Testing

View File

@ -3,7 +3,8 @@
"author": [
"[https://www.mediawiki.org/wiki/User:Bovender Daniel Kraus (bovender)]",
"Ulrich Strauss (c0nnex)",
"Brent Laabs (labster)"
"Brent Laabs (labster)",
"tetsuya-zama"
],
"type": "parserhook",
"url": "https://www.mediawiki.org/wiki/Extension:LinkTitles",

View File

@ -139,7 +139,7 @@ class Target {
public function getCaseSensitiveLinkValueRegex() {
if ( $this->caseSensitiveLinkValueRegex === null ) {
$regexSafeTitle = $this->getRegexSafeTitle();
if ( $this->config->capitalLinks && ( $regexSafeTitle[0] != '\\' )) {
if ( $this->config->capitalLinks && preg_match( '/[a-zA-Z]/', $regexSafeTitle[0] ) ) {
$this->caseSensitiveLinkValueRegex = '((?i)' . $regexSafeTitle[0] . '(?-i)' . substr($regexSafeTitle, 1) . ')';
} else {
$this->caseSensitiveLinkValueRegex = '(' . $regexSafeTitle . ')';