Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63179 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73522 invoked from network); 20 Sep 2012 04:11:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Sep 2012 04:11:52 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:48863] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FD/5C-15057-7879A505 for ; Thu, 20 Sep 2012 00:11:52 -0400 Received: by lbbgp3 with SMTP id gp3so2059504lbb.29 for ; Wed, 19 Sep 2012 21:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=+J1agcNsnWnpWtda0HVBNNyD+T4rUSFkJpRlolp29NE=; b=zQilZWZkLVU0KcDN7Bb4ni7dGnQOP2qtBkaP+YHOGZnj+aC3F7kf1XqI7TM2R9c8oE HEbtendjqpOGX6I4zRtifEvLPQ36/2wiC/lqvLSEaKv+NIMtFceJWOTSQZ+zP7vxcy2I ZW8geBDT//qeYvKNnCJ80T8rHS5pSqt2zQio0cmBlww3Aa5idKesDit3tOgQ/dKNde5y sK/XtNjPn2RXB2LefFFMnglkSH6Ji4fI0ZTVtUrzrH4i3jtIZKOD+H6muspJphDQg9tU IEevHrK95iJoeEhftU3m33M/UDJYWnfKp0573Nd4Xd822hvky5kkIu+LPXSCv36vuLht XQFg== MIME-Version: 1.0 Received: by 10.152.110.83 with SMTP id hy19mr428351lab.54.1348114308750; Wed, 19 Sep 2012 21:11:48 -0700 (PDT) Received: by 10.112.48.39 with HTTP; Wed, 19 Sep 2012 21:11:48 -0700 (PDT) In-Reply-To: <505A8CA3.50101@gmail.com> References: <0AC6EB13-3588-403B-BE73-968F12C7B7AF@gmail.com> <505A8CA3.50101@gmail.com> Date: Wed, 19 Sep 2012 22:11:48 -0600 Message-ID: To: David Muir Cc: Michael Shadle , =?ISO-8859-1?Q?P=E1draic_Brady?= , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC: Implementing a core anti-XSS escaping class From: morrison.levi@gmail.com (Levi Morrison) On Wed, Sep 19, 2012 at 9:25 PM, David Muir wrote: > On 20/09/12 07:48, Michael Shadle wrote: >> >> On Tue, Sep 18, 2012 at 10:32 AM, P=E1draic Brady >> wrote: >>> >>> Hi Michael, >>> >>> See the link near the bottom of the RFC - even htmlspecialchars() has >>> unusual behaviour that's potentially insecure. I have no objections to >>> there being functions, of course, and the RFC makes that clear. >>> However, many programmers like me are obsessed are objects so having >>> an SPL class will obviously be near and dear to my design patterned >>> heart ;). >> >> After looking over the RFC finally, would it be that crazy to consider >> this an extension of the standard string functions? >> >> str_escape($string, $encoding, $flags) or probably better >> str_escape($string, $flags, $encoding) - since encoding could be >> defaulted to UTF-8, but flags are really what differentiate the >> behavior... >> >> Then there is not a handful of functions but rather one that can be >> used as the abstraction point and the flags passed to it will change >> it's behavior, much like the filter functions. >> >> (I just see this falling under one solid defacto escape function >> standard, and it could live by itself as "escape" or something, or as >> it operates on strings, prefix it as such) >> > I'm on the fence with a default encoding. I tend to always use UTF-8, so > would probably just use the default. But that means I become less aware o= f > encoding being central to the issue, and therefore much easier to > accidentally leave it as UTF-8 when it should be something else. > > -1 on the flag based api, though. Would much rather have dedicated > functions. It's easier to read, and less verbose. > > > > "> > > > > >
> > > > > "> > > > > >
> > > > > escapeHtmlAttr($someTitle)?>"> > > > > >
escapeHtml($foo)?>escapeHtml($bar)?>
> > I prefer the OO API since it's succinct, but if we are to have a procedur= al > API as well, lets make it concise and clear. The last thing we want for > solving the no 1 security threat to web-apps is a confusing and hard-to-u= se > API like the filter extension. > > Cheers, > David > +1 to most of what you said. I will disagree on the filter extension. Its main problems are lack of publicity and functions with similar names that don't do what you would expect (Consider `is_int`). I use FILTER_VALIDATE_BOOLEAN and FILTER_VALIDATE_INT on a regular basis, and have used other filters. I will agree it's API could have been better, but it is not confusing in my opinion. I do want to make it clear that I support a simple, clean API if we do implement more escaping functions.