switch postcode tokens to new word table layout

This commit is contained in:
Sarah Hoffmann
2021-07-20 12:11:12 +02:00
parent 5ab0a63fd6
commit 5394b1fa1b
3 changed files with 26 additions and 17 deletions

View File

@@ -147,7 +147,7 @@ class Tokenizer
{
// Check which tokens we have, get the ID numbers
$sSQL = 'SELECT word_id, word_token, type';
$sSQL .= " info->>'cc' as country";
$sSQL .= " info->>'cc' as country, info->>'postcode' as postcode";
$sSQL .= ' FROM word WHERE word_token in (';
$sSQL .= join(',', $this->oDB->getDBQuotedList($aTokens)).')';
@@ -171,6 +171,16 @@ class Tokenizer
'H': // house number tokens
$oToken = new Token\HouseNumber($iId, $aWord['word_token']);
break;
'P': // postcode tokens
// Postcodes are not normalized, so they may have content
// that makes SQL injection possible. Reject postcodes
// that would need special escaping.
if ($aWord['postcode'] === null
|| pg_escape_string($aWord['postcode']) == $aWord['postcode']
) {
continue;
}
$oToken = new Token\Postcode($iId, $aWord['postcode'], null);
default:
continue;
}