Re: [GENERAL] text column constraint, newbie question

2009-03-25 Thread Stephen Cook
Daniel Verite wrote: Note that htmlentities() expects LATIN1-encoded strings and is thus unusable on UTF-8 contents. So if you end up talking UTF-8 with the database, you'll probably need to use htmlspecialchars() instead, and UTF-8 as your HTML charset. I believe you are wrong, at least the

Re: [GENERAL] text column constraint, newbie question

2009-03-25 Thread Daniel Verite
Stephen Cook wrote: Daniel Verite wrote: Note that htmlentities() expects LATIN1-encoded strings and is thus unusable on UTF-8 contents. So if you end up talking UTF-8 with the database, you'll probably need to use htmlspecialchars() instead, and UTF-8 as your HTML charset.

Re: [GENERAL] text column constraint, newbie question

2009-03-24 Thread Daniel Verite
RebeccaJ wrote: Thanks, everyone, for your contribution to this thread. I'm approaching the database design of my web application differently, now. Before, I was planning to have CHECK constraints in all of my text or char fields, to keep out all semicolons, single quotes, and anything

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread Stephen Cook
You should use pg_query_params() rather than build a SQL statement in your code, to prevent SQL injection attacks. Also, if you are going to read this data back out and show it on a web page you probably should make sure there is no rogue HTML or JavaScript or anything in there with

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread Scott Marlowe
On Mon, Mar 23, 2009 at 12:59 AM, Stephen Cook scli...@gmail.com wrote: You should use pg_query_params() rather than build a SQL statement in your code, to prevent SQL injection attacks. Also, if you are going to read this data back out and show it on a web page you probably should make sure

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread David Wilson
On Mon, Mar 23, 2009 at 3:07 AM, Scott Marlowe scott.marl...@gmail.com wrote: Are you saying pg_quer_params is MORE effective than pg_escape_string at deflecting SQL injection attacks? pg_query_params() will protect non-strings. For instance, read a number in from user input and do something

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread Ivan Sergio Borgonovo
On Mon, 23 Mar 2009 01:07:18 -0600 Scott Marlowe scott.marl...@gmail.com wrote: On Mon, Mar 23, 2009 at 12:59 AM, Stephen Cook scli...@gmail.com wrote: You should use pg_query_params() rather than build a SQL statement in your code, to prevent SQL injection attacks. Also, if you are going

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread Scott Marlowe
On Mon, Mar 23, 2009 at 2:33 AM, Ivan Sergio Borgonovo m...@webthatworks.it wrote: On Mon, 23 Mar 2009 01:07:18 -0600 Scott Marlowe scott.marl...@gmail.com wrote: On Mon, Mar 23, 2009 at 12:59 AM, Stephen Cook scli...@gmail.com wrote: You should use pg_query_params() rather than build a SQL

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread Ivan Sergio Borgonovo
On Mon, 23 Mar 2009 03:30:09 -0600 Scott Marlowe scott.marl...@gmail.com wrote: I think pg_query_params should make a difference between floats and integers and signal an error if you pass float where integers are expected... but I'm not sure. Not really a security concern, but an early

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread Sam Mason
On Mon, Mar 23, 2009 at 03:30:09AM -0600, Scott Marlowe wrote: On Mon, Mar 23, 2009 at 2:33 AM, Ivan Sergio Borgonovo m...@webthatworks.it wrote: On Mon, 23 Mar 2009 01:07:18 -0600 Scott Marlowe scott.marl...@gmail.com wrote: Are you saying pg_quer_params is MORE effective than

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread David Fetter
On Mon, Mar 23, 2009 at 01:07:18AM -0600, Scott Marlowe wrote: On Mon, Mar 23, 2009 at 12:59 AM, Stephen Cook scli...@gmail.com wrote: You should use pg_query_params() rather than build a SQL statement in your code, to prevent SQL injection attacks. Also, if you are going to read this data

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread RebeccaJ
On Mar 22, 12:36 pm, scott.marl...@gmail.com (Scott Marlowe) wrote: ayup. As long as they're legal for your encoding, they'll go right in. If you wanna stuff in anything no matter the encoding, use a database initialized for SQL_ASCII encoding. Thanks, everyone, for your contribution to this

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread Scott Marlowe
On Mon, Mar 23, 2009 at 3:11 PM, RebeccaJ rebec...@gmail.com wrote: Scott, your comment above introduced some new concepts to me, and now I'm thinking about foreign language text and other ways to be more flexible. I found this page that talks about encoding:

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread Ivan Sergio Borgonovo
On Mon, 23 Mar 2009 14:11:28 -0700 (PDT) RebeccaJ rebec...@gmail.com wrote: now. Before, I was planning to have CHECK constraints in all of my text or char fields, to keep out all semicolons, single quotes, and anything else that looked dangerous. Now I'm thinking that I'll be using

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread Alban Hertroys
On Mar 23, 2009, at 10:11 PM, RebeccaJ wrote: On Mar 22, 12:36 pm, scott.marl...@gmail.com (Scott Marlowe) wrote: ayup. As long as they're legal for your encoding, they'll go right in. If you wanna stuff in anything no matter the encoding, use a database initialized for SQL_ASCII encoding.

Re: [GENERAL] text column constraint, newbie question

2009-03-23 Thread Craig Ringer
RebeccaJ wrote: And I wonder why you like SQL_ASCII better than UTF8, and whether others have any opinions about those two. (My web server's LC_CTYPE is C, so I can use any character set.) Wouldn't UTF8 allow more characters than SQL_ASCII? I've had a LOT of experience dealing with apps that

[GENERAL] text column constraint, newbie question

2009-03-22 Thread RebeccaJ
Hi, I'm new to both PostgreSQL and web-based application development; I read the FAQ at postgresql.org (perhaps this discussion group has another FAQ that I haven't found yet?) and didn't see this addressed. I'm creating a table with a column of type text, to be used in a php web application,

Re: [GENERAL] text column constraint, newbie question

2009-03-22 Thread Scott Marlowe
On Sat, Mar 21, 2009 at 11:13 PM, RebeccaJ rebec...@gmail.com wrote: Hi, I'm new to both PostgreSQL and web-based application development; I read the FAQ at postgresql.org (perhaps this discussion group has another FAQ that I haven't found yet?) and didn't see this addressed. I'm creating a

Re: [GENERAL] text column constraint, newbie question

2009-03-22 Thread RebeccaJ
Are there characters, maybe non-printing characters, or perhaps even whole phrases, that could cause problems in my database or application if I were to allow users to enter them into that column? If so, does anyone happen to have a regular expression handy that you think is a good

Re: [GENERAL] text column constraint, newbie question

2009-03-22 Thread Scott Marlowe
On Sun, Mar 22, 2009 at 11:36 AM, RebeccaJ rebec...@gmail.com wrote:  Are there characters, maybe non-printing characters, or perhaps even whole phrases, that could cause problems in my database or application if I were to allow users to enter them into that column? If so, does anyone