From: Sarah Hoffmann Date: Sun, 29 Mar 2015 15:23:06 +0000 (+0200) Subject: correctly quote regular expression X-Git-Tag: v2.4.0~9 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/aaabf70a1c59b1d8815459c7cd54cdd4cfb5be9e correctly quote regular expression --- diff --git a/lib/Geocode.php b/lib/Geocode.php index 9ee812d4..dfb3af2a 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -1591,9 +1591,11 @@ $aRecheckWords = preg_split('/\b[\s,\\-]*/u',$sQuery); foreach($aRecheckWords as $i => $sWord) { - if (!$sWord) unset($aRecheckWords[$i]); + if (!preg_match('/\pL/', $sWord)) unset($aRecheckWords[$i]); } + if (CONST_Debug) { echo 'Recheck words:<\i>'; var_dump($aRecheckWords); } + foreach($aSearchResults as $iResNum => $aResult) { if (CONST_Search_AreaPolygons) @@ -1752,7 +1754,7 @@ if (stripos($sAddress, $sWord)!==false) { $iCountWords++; - if (preg_match("/(^|,)\s*$sWord\s*(,|$)/", $sAddress)) $iCountWords += 0.1; + if (preg_match("/(^|,)\s*".preg_quote($sWord, '/')."\s*(,|$)/", $sAddress)) $iCountWords += 0.1; } }