Skip to content

Commit a81e65a

Browse files
committed
Remove xsl.security_prefs ini option
Conflicts: ext/xsl/php_xsl.c ext/xsl/xsltprocessor.c
1 parent b5184ef commit a81e65a

File tree

5 files changed

+11
-74
lines changed

5 files changed

+11
-74
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,6 @@
169169

170170
- XSL:
171171
. Fixed bug #64776 (The XSLT extension is not thread safe). (Mike)
172+
. Removed xsl.security_prefs ini option. (Nikita)
172173

173174
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ Other
395395
- Stream:
396396
. Removed set_socket_blocking() in favor of its alias stream_set_blocking().
397397

398+
- XSL:
399+
. Removed xsl.security_prefs ini option. Use XsltProcessor::setSecurityPrefs()
400+
instead.
401+
398402
========================================
399403
2. New Features
400404
========================================

ext/xsl/php_xsl.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,6 @@ zend_object *xsl_objects_new(zend_class_entry *class_type)
129129
}
130130
/* }}} */
131131

132-
PHP_INI_BEGIN()
133-
/* Default is not allowing any write operations.
134-
XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_NETWORK | XSL_SECPREF_WRITE_FILE == 44
135-
*/
136-
PHP_INI_ENTRY("xsl.security_prefs", "44", PHP_INI_ALL, NULL)
137-
PHP_INI_END()
138-
139132
/* {{{ PHP_MINIT_FUNCTION
140133
*/
141134
PHP_MINIT_FUNCTION(xsl)
@@ -181,8 +174,6 @@ PHP_MINIT_FUNCTION(xsl)
181174
REGISTER_STRING_CONSTANT("LIBEXSLT_DOTTED_VERSION", LIBEXSLT_DOTTED_VERSION, CONST_CS | CONST_PERSISTENT);
182175
#endif
183176

184-
REGISTER_INI_ENTRIES();
185-
186177
return SUCCESS;
187178
}
188179
/* }}} */
@@ -260,8 +251,6 @@ PHP_MSHUTDOWN_FUNCTION(xsl)
260251
xsltSetGenericErrorFunc(NULL, NULL);
261252
xsltCleanupGlobals();
262253

263-
UNREGISTER_INI_ENTRIES();
264-
265254
return SUCCESS;
266255
}
267256
/* }}} */

ext/xsl/tests/bug54446_with_ini.phpt

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ if (file_exists($outputfile)) {
4444
}
4545

4646
#SET NO SECURITY PREFS
47-
ini_set("xsl.security_prefs", XSL_SECPREF_NONE);
47+
$proc->setSecurityPrefs(XSL_SECPREF_NONE);
4848

49-
# TRASNFORM & PRINT
49+
# TRANSFORM & PRINT
5050
print $proc->transformToXML( $dom );
5151

5252

@@ -59,9 +59,9 @@ if (file_exists($outputfile)) {
5959
unlink($outputfile);
6060

6161
#SET SECURITY PREFS AGAIN
62-
ini_set("xsl.security_prefs", XSL_SECPREF_WRITE_FILE | XSL_SECPREF_WRITE_NETWORK | XSL_SECPREF_CREATE_DIRECTORY);
62+
$proc->setSecurityPrefs(XSL_SECPREF_WRITE_FILE | XSL_SECPREF_WRITE_NETWORK | XSL_SECPREF_CREATE_DIRECTORY);
6363

64-
# TRASNFORM & PRINT
64+
# TRANSFORM & PRINT
6565
print $proc->transformToXML( $dom );
6666

6767
if (file_exists($outputfile)) {
@@ -70,31 +70,7 @@ if (file_exists($outputfile)) {
7070
print "OK, no file created\n";
7171
}
7272

73-
#SET NO SECURITY PREFS with ini, but set them with ->setSecurityPrefs
74-
ini_set("xsl.security_prefs", XSL_SECPREF_NONE);
75-
$proc->setSecurityPrefs( XSL_SECPREF_WRITE_FILE | XSL_SECPREF_WRITE_NETWORK | XSL_SECPREF_CREATE_DIRECTORY);
76-
77-
print $proc->transformToXML( $dom );
78-
if (file_exists($outputfile)) {
79-
print "$outputfile exists, but shouldn't!\n";
80-
} else {
81-
print "OK, no file created\n";
82-
}
83-
84-
#don't throw a warning if both ini and through-the-method have the same value
85-
$proc->setSecurityPrefs(XSL_SECPREF_NONE);
86-
87-
print $proc->transformToXML( $dom );
88-
89-
if (file_exists($outputfile)) {
90-
print "OK, file exists\n";
91-
} else {
92-
print "$outputfile doesn't exist, but should!\n";
93-
}
94-
unlink($outputfile);
95-
96-
97-
73+
?>
9874
--EXPECTF--
9975
Warning: XSLTProcessor::transformToXml(): runtime error: file %s line %s element output in %s on line %d
10076

@@ -104,8 +80,6 @@ Warning: XSLTProcessor::transformToXml(): runtime error: file %s line %d element
10480

10581
Warning: XSLTProcessor::transformToXml(): xsltDocumentElem: write rights for %s/bug54446test.txt denied in %s on line %d
10682
OK, no file created
107-
108-
Deprecated: XSLTProcessor::transformToXml(): The xsl.security_prefs php.ini option is deprecated; use XsltProcessor->setSecurityPrefs() instead in %s on line %d
10983
OK, file exists
11084

11185
Warning: XSLTProcessor::transformToXml(): runtime error: file %s line %s element output in %s on line %d
@@ -116,20 +90,6 @@ Warning: XSLTProcessor::transformToXml(): runtime error: file %s line %d element
11690

11791
Warning: XSLTProcessor::transformToXml(): xsltDocumentElem: write rights for %s/bug54446test.txt denied in %s on line %d
11892
OK, no file created
119-
120-
Deprecated: XSLTProcessor::transformToXml(): The xsl.security_prefs php.ini option is deprecated; use XsltProcessor->setSecurityPrefs() instead in %s on line %d
121-
122-
Notice: XSLTProcessor::transformToXml(): The xsl.security_prefs php.ini was not used, since the XsltProcessor->setSecurityPrefs() method was used in %s on line %d
123-
124-
Warning: XSLTProcessor::transformToXml(): runtime error: file %s line %s element output in %s on line %d
125-
126-
Warning: XSLTProcessor::transformToXml(): File write for %s/bug54446test.txt refused in %s on line %s
127-
128-
Warning: XSLTProcessor::transformToXml(): runtime error: file %s line %d element output in %s on line %d
129-
130-
Warning: XSLTProcessor::transformToXml(): xsltDocumentElem: write rights for %s/bug54446test.txt denied in %s on line %d
131-
OK, no file created
132-
OK, file exists
13393
--CREDITS--
13494
Christian Stocker, [email protected]
13595

ext/xsl/xsltprocessor.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl
483483
zend_object_handlers *std_hnd;
484484
FILE *f;
485485
int secPrefsError = 0;
486-
int secPrefsValue, secPrefsIni;
486+
int secPrefsValue;
487487
xsltSecurityPrefsPtr secPrefs = NULL;
488488

489489
node = php_libxml_import_node(docp);
@@ -542,23 +542,6 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl
542542

543543
secPrefsValue = intern->securityPrefs;
544544

545-
/* This whole if block can be removed, when we remove the xsl.security_prefs php.ini option in PHP 6+ */
546-
secPrefsIni= INI_INT("xsl.security_prefs");
547-
/* if secPrefsIni has the same value as secPrefsValue, all is fine */
548-
if (secPrefsIni != secPrefsValue) {
549-
if (secPrefsIni != XSL_SECPREF_DEFAULT) {
550-
/* if the ini value is not set to the default, throw an E_DEPRECATED warning */
551-
php_error_docref(NULL, E_DEPRECATED, "The xsl.security_prefs php.ini option is deprecated; use XsltProcessor->setSecurityPrefs() instead");
552-
if (intern->securityPrefsSet == 0) {
553-
/* if securityPrefs were not set through the setSecurityPrefs method, take the ini setting */
554-
secPrefsValue = secPrefsIni;
555-
} else {
556-
/* else throw a notice, that the ini setting was not used */
557-
php_error_docref(NULL, E_NOTICE, "The xsl.security_prefs php.ini was not used, since the XsltProcessor->setSecurityPrefs() method was used");
558-
}
559-
}
560-
}
561-
562545
/* if securityPrefs is set to NONE, we don't have to do any checks, but otherwise... */
563546
if (secPrefsValue != XSL_SECPREF_NONE) {
564547
secPrefs = xsltNewSecurityPrefs();

0 commit comments

Comments
 (0)