Gossamer Forum
Home : Products : DBMan : Installation :

Delimiter problem

Quote Reply
Delimiter problem
I tried to use 2 symbols for delimiter,
because if the delimiter appears in one of the records, the whole db will mess up.

However, I found that my date entry, which
is also my last field always include the
second symbol, (ie. if I use !# for delimiter, the date will become 1-Jan-1999# ) I
wonder if there is a solution for this problem. Cheers alot.

Quote Reply
Re: Delimiter problem In reply to
I think you have to use just one symbol as a delimiter. Isn't there something you can be sure won't be part of a record?


------------------
JPD
Quote Reply
Re: Delimiter problem In reply to
Your right, this is a bug. In &join_encode replace:

chop $output;

with:

$output =~ s/\Q$db_delim\E$//o;

This bug should only appear when your delimiter is more then one character.

By the way, adding the delimiter into the database shouldn't cause problems. You can add a | character into the database.

Cheers,

Alex
Quote Reply
Re: Delimiter problem In reply to
The reason to use 2 delimiters is that
I would like to set up a db using
double-byte characters, and would also
want to allow users to enter data, while
preventing them to deliberatly damage the
database... hiding the delimiters combination
will do the trick I thought.
Quote Reply
Re: Delimiter problem In reply to
 
Quote:
I would like to set up a db using
double-byte characters

That I can't help you with, because I'm not really sure what you mean.

Quote:
want to allow users to enter data, while preventing them to deliberatly damage the database...

There should be something you could add to the validate_record subroutine in db.cgi to prevent this. Something like:

after

else { # else entry is not null.
($db_valid_types{$col} && !($in{$col} =~ /$db_valid_types{$col}/)) and
push(@input_err, "$col (Invalid format)"); # but has failed validation.
}

add

if ($in{$col}) =~ /$db_delim/) {
push(@input_err, "$col (Includes a disallowed character -- $db_delim)");
}


It's untested, but I don't see why it wouldn't work. I use something like that as a "dirty word" censor.

This is not a bad idea for everyone to have. I've been learning how sneaky and malicious some users can be.



------------------
JPD
Quote Reply
Re: Delimiter problem In reply to
Oh, thanks alot, I'll give it a try.

About double-byte characters, I mean
Chinese characters / Japanese characters,
these fonts take 2 bytes per character
instead of one.

Therefore I found that some chinese characters contains the equvilant byte for "|", so
the db sometimes doesn't quite work.

Anyway I think you solution will work. Thanks again.
Quote Reply
Re: Delimiter problem In reply to
Phew!

I've made a number of DBman projects recently and I work primarily in a Chinese Windows environment. Up until now, I'd completely overlooked this problem (that the delimiter could be encased in a double-byte character) Shame on me! All I've done is adjusted print qq delimiters to accomodate some -- I should have seen the double-byte character conflicts coming a mile away.

My workaround solution for the print qq was simply to use .gif pictures in place of the offending Chinese text -- not a good solution at all.

QUESTION:
Are there ANY keyboard characters that would not conflict with either double-byte fonts/text or regular western syntax?


I'm going to implement these fixes, and also try to use a double delimiter (I've been told that a double ampersand -- && -- makes for a great delimiter in other Chinese database applications).

Many thanks to kwli for bringing up this issue.
Wo juede ni shi Chung-guo ren, dui bu dui?

[This message has been edited by taiwangus (edited December 03, 1999).]