Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23aad18

Browse files
committed
Make contrib/unaccent's unaccent() function work when not in search path.
Since the fixes forCVE-2018-1058, we've advised people to schema-qualifyfunction references in order to fix failures in code that executes undera minimal search_path setting. However, that's insufficient to make thesingle-argument form of unaccent() work, because it looks up the "unaccent"text search dictionary using the search path.The most expedient answer seems to be to remove the search_path dependencyby making it look in the same schema that the unaccent() function itselfis declared in. This will definitely work for the normal usage of thisfunction with the unaccent dictionary provided by the extension.It's barely possible that there are people who were relying on thesearch-path-dependent behavior to select other dictionaries with the samename; but if there are any such people at all, they can still get thatbehavior by writing unaccent('unaccent', ...), or possiblyunaccent('unaccent'::text::regdictionary, ...) if the lookup has to bepostponed to runtime.Per complaint from Gunnlaugur Thor Briem. Back-patch to all supportedbranches.Discussion:https://postgr.es/m/CAPs+M8LCex6d=DeneofdsoJVijaG59m9V0ggbb3pOH7hZO4+cQ@mail.gmail.com
1 parent834bce0 commit23aad18

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

‎contrib/unaccent/unaccent.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#include"tsearch/ts_locale.h"
2121
#include"tsearch/ts_public.h"
2222
#include"utils/builtins.h"
23+
#include"utils/lsyscache.h"
2324
#include"utils/regproc.h"
25+
#include"utils/syscache.h"
2426

2527
PG_MODULE_MAGIC;
2628

@@ -376,7 +378,21 @@ unaccent_dict(PG_FUNCTION_ARGS)
376378

377379
if (PG_NARGS()==1)
378380
{
379-
dictOid=get_ts_dict_oid(stringToQualifiedNameList("unaccent"), false);
381+
/*
382+
* Use the "unaccent" dictionary that is in the same schema that this
383+
* function is in.
384+
*/
385+
Oidprocnspid=get_func_namespace(fcinfo->flinfo->fn_oid);
386+
constchar*dictname="unaccent";
387+
388+
dictOid=GetSysCacheOid2(TSDICTNAMENSP,
389+
PointerGetDatum(dictname),
390+
ObjectIdGetDatum(procnspid));
391+
if (!OidIsValid(dictOid))
392+
ereport(ERROR,
393+
(errcode(ERRCODE_UNDEFINED_OBJECT),
394+
errmsg("text search dictionary \"%s.%s\" does not exist",
395+
get_namespace_name(procnspid),dictname)));
380396
strArg=0;
381397
}
382398
else

‎doc/src/sgml/unaccent.sgml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,14 @@ mydb=# select ts_headline('fr','Hôtel de la Mer',to_tsquery('fr','Hotels')
174174
</indexterm>
175175

176176
<synopsis>
177-
unaccent(<optional><replaceable class="parameter">dictionary</replaceable>, </optional> <replaceable class="parameter">string</replaceable>) returns <type>text</type>
177+
unaccent(<optional><replaceable class="parameter">dictionary</replaceable> <type>regdictionary</type>, </optional> <replaceable class="parameter">string</replaceable> <type>text</type>) returns <type>text</type>
178178
</synopsis>
179179

180180
<para>
181181
If the <replaceable class="parameter">dictionary</replaceable> argument is
182-
omitted, <literal>unaccent</literal> is assumed.
182+
omitted, the text search dictionary named <literal>unaccent</literal> and
183+
appearing in the same schema as the <function>unaccent()</function>
184+
function itself is used.
183185
</para>
184186

185187
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp