Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55636 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27866 invoked from network); 27 Sep 2011 07:04:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Sep 2011 07:04:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.215.170 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.215.170 mail-ey0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:49897] helo=mail-ey0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/E1-08680-475718E4 for ; Tue, 27 Sep 2011 03:04:22 -0400 Received: by eyh6 with SMTP id 6so4183649eyh.29 for ; Tue, 27 Sep 2011 00:04:17 -0700 (PDT) Received: by 10.14.15.83 with SMTP id e59mr2464135eee.191.1317107057064; Tue, 27 Sep 2011 00:04:17 -0700 (PDT) Received: from [192.168.5.49] (79-98-74-44.sys-data.com. [79.98.74.44]) by mx.google.com with ESMTPS id f16sm28504962eec.8.2011.09.27.00.04.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 27 Sep 2011 00:04:15 -0700 (PDT) References: <4E80BD8A.5070606@liip.ch> <4E81590C.1030507@liip.ch> In-Reply-To: <4E81590C.1030507@liip.ch> Mime-Version: 1.0 (iPad Mail 8J2) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-ID: Cc: PHPdev X-Mailer: iPad Mail (8J2) Date: Tue, 27 Sep 2011 09:04:16 +0200 To: Christian Stocker Subject: Re: [PHP-DEV] Question about ABI compatibility for an ext/xsl patch and an API question for the implementation From: rasmus@lerdorf.com (Rasmus Lerdorf) This sounds like the best approach actually. On Sep 27, 2011, at 7:03 AM, Christian Stocker w= rote: > Hi again >=20 > I just had the idea for a 4th option. Won't be less controversy, but > it's backwards and forwards compatible. >=20 > 4) use a php ini setting in PHP 5.3 >=20 > I know, we try to avoid that as much as possible. BUT >=20 > * It will only be in 5.3, not even committed to 5.4 > * If you don't have the ini setting, your XSLT can't write files, the > error will be pretty obvious. If you just read and transform, nothing > will or has to change > * Only a very very very small fraction will need to set this ini setting >=20 > The code for enable writing again, which would work in 5.0 - 5.4+ looks > like this. With my first proposal, I'd need much more if/else to make my > code work on 5.3.8-/5.3.9+/5.4+ >=20 > *** > $xsl =3D new XSLTProcessor(); >=20 > //if you want to write from within the XSLT > $oldvalini =3D ini_set("xsl_security_prefs",XSL_SECPREFS_NONE); > if (version_compare(PHP_VERSION,'5.4',">=3D")) { > $oldval =3D $xsl->setSecurityPreferences(XSL_SECPREFS_NONE); > } >=20 > $xsl->transformToXml(...); >=20 > //go back to the old setting. Better safe than sorry > ini_set("xsl_security_prefs",$oldvalini); > if (version_compare(PHP_VERSION,'5.4',">=3D")) { > $xsl->setSecurityPreferences($oldval); > } > *** >=20 > chregu >=20 >=20 >=20 >=20 > On 26.09.11 19:59, Christian Stocker wrote: >> Hi >>=20 >> Some weeks ago I wrote a patch to disable writing from within XSLT >> templates. That patch is now in 5.4 but wasn't accepted in PHP 5.3 since >> it changed a struct in the header file. >>=20 >> I have now I new patch which doesn't need that changing in the struct, >> but I need a new .h file from libxslt. >>=20 >> https://gist.github.com/3d3d3c3418236f748118 (unfinished patch, just a >> proof of concept, but the basics are there) >>=20 >> Can anybody tell me, if that still breaks binary compatibility for >> extensions or if that would be ok? >>=20 >> Then a more general question: >>=20 >> There are now 2 ways to enable write access again (in 5.4). Via an >> additional optional parameter to the transform methods (this works with >> the patch above in 5.3 also) or via the new 5.4 only method >> ->setSecurityPrefs(). The former is from a clean API point of view not >> nice, adding more and more optional parameters to methods is the ticket >> to hell usually. But I can't come up with a better solution for 5.3 >> without breaking the ABI. And since it's somehow a security issue, I >> would sleep better a lot, if we have a proper patch for 5.3 as well. >>=20 >> To keep BC, I can't just delete the optional parameter again for 5.4, >> that would make portable code a pain. OTOH, the way I did it know, it >> breaks BC with PHP < 5.3.9, if you want to enable write access in xslt >> templates in PHP 5.3.9+. If you don't need that, which is maybe 99.9% of >> all cases, BC is kept for since PHP 5.0 until much after PHP 5.4 :) >>=20 >> So there are 3 options >>=20 >> 1) leave it like it is currently. No write protection in 5.3, only in 5.4= >> 2) Have 2 ways to enable write access from 5.3.9+ and 5.4. >> 3) Remove the ->setSecurityPrefs() in 5.4, so there's only one way to >> enable write access again, but it's the nasty one from a clean API POV. >>=20 >> For 2) and 3), code with those new options won't work anymore in 5.3.8- >> (but you can check it in PHP user land and treat it differently), but >> you get write protection automatically >>=20 >> Again, all this will only affect a very small fraction of users, those >> who legitimately wrote files from within XSLT. >>=20 >> Any opinions? Me personally would like to have it in PHP 5.3 (or at >> least offer a proper patch). >>=20 >> chregu >>=20 >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20