FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Rejecting Certain Non-ASCII Characters
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Rejecting Certain Non-ASCII Characters [message #181191 is a reply to message #181187] Sat, 20 April 2013 01:34 Go to previous messageGo to previous message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma:
Member
Jerry Stuckle wrote:
> On 4/19/2013 8:36 PM, Christoph Becker wrote:
>> Jerry Stuckle wrote:
>>> On 4/19/2013 6:26 PM, Christoph Becker wrote:
>>>> Jim Higgins wrote:
>>>> > On Fri, 19 Apr 2013 19:38:02 +0200, in
>>>> > <kkrvda$od5$1(at)speranza(dot)aioe(dot)org>, Christoph Becker <cmbecker69(at)gmx(dot)de>
>>>> > wrote:
>>>> >
>>>> >> Jim Higgins wrote:
>>>> >>> I have a problem with people entering a slashed zero vs a standard
>>>> >>> ASCII zero into HTML forms intended to store data in a MySQL
>>>> >>> database.
>>>> >>
>>>> >> Is it really a slashed zero (U+0030 U+0338) they're entering, or do
>>>> >> they
>>>> >> enter some similar looking character such as the Danish Ø? In the
>>>> >> former case you can simply replace the slashed zero with a standard
>>>> >> zero. Assuming UTF-8 encoding:
>>>> >>
>>>> >> $input = str_replace('\xCC\xB8', '', $input);
>>>> >
>>>> >
>>>> > It's usually 0x41 0x7E, but sometimes 0xD8.
>>>>
>>>> 0xD8 is Ø in ISO-8859-1 for example; I do not know which character
>>>> encoding represents the same or a similar character as 0x41 0x7E.
>>>> Anyway, ISTM you're missing to enforce a particular character encoding
>>>> for your document (see <http://www.w3.org/TR/html4/charset.html> for
>>>> HTML 4.01 documents).
>>>>
>>>
>>> This is a recommendation only. The browser is free to ignore it. There
>>> is no way to force a browser to do anything in HTML.
>>
>> The mentioned W3C recommendation also elaborates on the "charset"
>> parameter of the "Content-Type" header, which should be respected by all
>> user agents conforming to RFC 2616, if they have requested the URI with
>> a suitable "Accept-Charset" header. Otherwise the PHP script may
>> respond with "406 Not acceptable" (and a body explaining the
>> requirements).
>>
>
> SHOULD BE RESPECTED is the key phrase here.
>
> All HTML is recommendations - including the charset.

A HTTP response header has nothing to do with HTML as you know.

> Not all browsers
> follow all recommendations - or follow them the same way.
>
> It does not guarantee you will not get non-ASCII characters, especially
> if the user is using a non-ASCII charset.

I didn't want to suggest to send

Content-Type: text/html; charset=ASCII

I merely noticed, that a developer should be aware of charset issues and
do the best he can to /minimize/ unexpected or even arbitrary behavior.
Letting the user agent /guess/ how the response is encoded
(respectively rely on the webserver's default), and how it should encode
the follow-up request is surely not the best solution.

> And PHP will not respond with a 406 unless the user sends a 406. PHP
> has no idea what charset is set in the outgoing header.

Of course. Therefore I've written "the PHP script ...". The word
"script" was intended to imply, that the script author is responsible
for doing this.

--
Christoph M. Becker
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: googleapi problem
Next Topic: Undefined variable
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Dec 01 02:17:26 GMT 2024

Total time taken to generate the page: 5.51458 seconds