Skip site navigation (1) Skip section navigation (2)

adjust chr()/ascii() to prevent invalidly encoded data

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: adjust chr()/ascii() to prevent invalidly encoded data
Date: 2007-09-14 15:55:58
Message-ID: 46EAAF0E.5090501@dunslane.net (view raw or flat)
Thread:
Lists: pgsql-patches
The attached patch is intended to ensure that chr() does not produce 
invalidly encoded data, as recently discussed on -hackers. For UTF8, we 
treat its argument as a Unicode code point; for all other multi-byte 
encodings, we raise an error on any argument greater than 127. For all 
encodings we raise an error if the argument is 0 (we don't allow null 
bytes in text data). The ascii() function is adjusted so that it remains 
the inverse of chr() - i.e. for UTF8 it returns the Unicode code point, 
and it raises an error for any other multi-byte encoding if the 
aregument is outside the ASCII range. I have tested thius inverse 
property across the entire Unicode code point range, 0x01 .. 0x1ffff.

TODO: alter docs to reflect changes.

cheers

andrew



Attachment: codfix2.patch
Description: text/x-patch (5.4 KB)

Responses

pgsql-patches by date

Next:From: Bruce MomjianDate: 2007-09-14 15:58:05
Subject: Re: GSS warnings
Previous:From: Bruce MomjianDate: 2007-09-14 14:54:26
Subject: Re: Linkage for escape strings

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group