Previously things like "192.168.1.1" couldn't be searched very cleanly in the MySQL backend for two reasons:
* First, the periods were stripped out. This resulted in it being broken into multiple short words: "192 168 1 1", leading at best to false positives and general weirdness.
* Second, for IP addresses these were shorter than the default minimum word length of 4 and thus didn't even get indexed!
The addition of padding for short words let them at least get indexed, but they still didn't turn up cleanly due to the word split. Now allowing periods through to the indexed text, and encoding periods that appear within a compound word so they get caught more cleanly.
Also made a tweak so highlighting works a bit better on word boundaries -- eg "192.168.1.1" no longer hits a highlight match for "192.168.1.100". However it's still not 100% handling some cases with the periods. Sigh.
DB environments when $wgDBserver isn't set.
* (bug 3691) Aspect ratio from viewBox attribute is now preserved for SVG
images which do not specify width and height attributes.
+* (bug 15027) Internet domain names and IP addresses can now be indexed and
+ searched sensibly with the default MySQL search backend.
=== API changes in 1.14 ===
}
public static function legalSearchChars() {
- return "A-Za-z_'0-9\\x80-\\xFF\\-";
+ return "A-Za-z_'.0-9\\x80-\\xFF\\-";
}
/**
if( !empty( $terms[3] ) ) {
// Match individual terms in result highlighting...
$regexp = preg_quote( $terms[3], '/' );
- if( $terms[4] ) $regexp .= "[0-9A-Za-z_]+";
+ if( $terms[4] ) {
+ $regexp = "\b$regexp"; // foo*
+ } else {
+ $regexp = "\b$regexp\b";
+ }
} else {
// Match the quoted term in result highlighting...
$regexp = preg_quote( str_replace( '"', '', $terms[2] ), '/' );
$out );
}
+ // Periods within things like hostnames and IP addresses
+ // are also important -- we want a search for "example.com"
+ // or "192.168.1.1" to work sanely.
+ //
+ // MySQL's search seems to ignore them, so you'd match on
+ // "example.wikipedia.com" and "192.168.83.1" as well.
+ $out = preg_replace(
+ "/(\w)\.(\w|\*)/u",
+ "$1U82e$2",
+ $out );
+
wfProfileOut( __METHOD__ );
return $out;
}