Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63081 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81832 invoked from network); 18 Sep 2012 17:31:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Sep 2012 17:31:53 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 64.22.89.133 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 64.22.89.133 oxmail.registrar-servers.com Received: from [64.22.89.133] ([64.22.89.133:55884] helo=oxmail.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3F/F5-07072-800B8505 for ; Tue, 18 Sep 2012 13:31:53 -0400 Received: from [192.168.0.200] (5ad4bfa1.bb.sky.com [90.212.191.161]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by oxmail.registrar-servers.com (Postfix) with ESMTPSA id 750BB7580D9; Tue, 18 Sep 2012 13:31:49 -0400 (EDT) Message-ID: <5058AFD7.7080703@ajf.me> Date: Tue, 18 Sep 2012 18:31:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: Steve Clay CC: PHP Internals References: <5058AD25.8010304@mrclay.org> In-Reply-To: <5058AD25.8010304@mrclay.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: Implementing a core anti-XSS escaping class From: ajf@ajf.me (Andrew Faulds) On 18/09/12 18:19, Steve Clay wrote: > > First issue: I've not studied the referenced PHP implementations, but > in cases where multiple contexts seem to apply it's not clear from the > RFC which function(s) should be used, and if multiple, how their calls > would be composed. Examples: > > HTML style attribute: escapeHtmlAttr, escapeCss, or both? > HTML on* attributes: escapeHtmlAttr, escapeJs, or both? > HTML href/src attributes: escapeHtmlAttrs, escapeUrl, or both? > HTML script/style elements: Is escapeHtml needed? > > I can probably correctly guess some of these, but I think ideally the > method and class names should make this more obvious. If escapeJs is > only for string literals in JS code (again, the name doesn't make that > clear to me), what does escapeCss actually do, since string literals > aren't very common in CSS? I echo this. I think some clearer names might help, I think something like these: escapeHTMLAttribute for attributes, escapeHTMLText for text inside tags, escapeXMLAttribute and escapeXMLContent, escapeJSStringLiteral, escapeCSSIdentifier, and another needs adding (for url('*') things), escapeCSSStringLiteral. -- Andrew Faulds http://ajf.me/