Field cleanups in xsl_object (#13182)

This commit is contained in:
Niels Dossche 2024-01-17 21:29:48 +01:00 committed by GitHub
parent 569da8a064
commit 76a3eddfd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 9 deletions

View file

@ -49,14 +49,13 @@ extern zend_module_entry xsl_module_entry;
#define XSL_SECPREF_CREATE_DIRECTORY 8 #define XSL_SECPREF_CREATE_DIRECTORY 8
#define XSL_SECPREF_READ_NETWORK 16 #define XSL_SECPREF_READ_NETWORK 16
#define XSL_SECPREF_WRITE_NETWORK 32 #define XSL_SECPREF_WRITE_NETWORK 32
/* Default == disable all write access == XSL_SECPREF_WRITE_NETWORK | XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE */ /* Default == disable all write access */
#define XSL_SECPREF_DEFAULT 44 #define XSL_SECPREF_DEFAULT (XSL_SECPREF_WRITE_NETWORK | XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE)
typedef struct _xsl_object { typedef struct _xsl_object {
void *ptr; void *ptr;
HashTable *parameter; HashTable *parameter;
int hasKeys; bool hasKeys;
int securityPrefsSet;
zend_long securityPrefs; zend_long securityPrefs;
php_dom_xpath_callbacks xpath_callbacks; php_dom_xpath_callbacks xpath_callbacks;
php_libxml_node_object *doc; php_libxml_node_object *doc;

View file

@ -181,14 +181,14 @@ PHP_METHOD(XSLTProcessor, importStylesheet)
if (nodep && (nodep = nodep->children)) { if (nodep && (nodep = nodep->children)) {
while (nodep) { while (nodep) {
if (nodep->type == XML_ELEMENT_NODE && xmlStrEqual(nodep->name, (const xmlChar *) "key") && xmlStrEqual(nodep->ns->href, XSLT_NAMESPACE)) { if (nodep->type == XML_ELEMENT_NODE && xmlStrEqual(nodep->name, (const xmlChar *) "key") && xmlStrEqual(nodep->ns->href, XSLT_NAMESPACE)) {
intern->hasKeys = 1; intern->hasKeys = true;
break; break;
} }
nodep = nodep->next; nodep = nodep->next;
} }
} }
} else { } else {
intern->hasKeys = clone_docu; intern->hasKeys = true;
} }
if ((oldsheetp = (xsltStylesheetPtr)intern->ptr)) { if ((oldsheetp = (xsltStylesheetPtr)intern->ptr)) {
@ -257,7 +257,7 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl
intern->doc = emalloc(sizeof(php_libxml_node_object)); intern->doc = emalloc(sizeof(php_libxml_node_object));
memset(intern->doc, 0, sizeof(php_libxml_node_object)); memset(intern->doc, 0, sizeof(php_libxml_node_object));
if (intern->hasKeys == 1) { if (intern->hasKeys) {
doc = xmlCopyDoc(doc, 1); doc = xmlCopyDoc(doc, 1);
} else { } else {
object = Z_LIBXML_NODE_P(docp); object = Z_LIBXML_NODE_P(docp);
@ -681,8 +681,6 @@ PHP_METHOD(XSLTProcessor, setSecurityPrefs)
intern = Z_XSL_P(id); intern = Z_XSL_P(id);
oldSecurityPrefs = intern->securityPrefs; oldSecurityPrefs = intern->securityPrefs;
intern->securityPrefs = securityPrefs; intern->securityPrefs = securityPrefs;
/* set this to 1 so that we know, it was set through this method. Can be removed, when we remove the ini setting */
intern->securityPrefsSet = 1;
RETURN_LONG(oldSecurityPrefs); RETURN_LONG(oldSecurityPrefs);
} }
/* }}} end XSLTProcessor::setSecurityPrefs */ /* }}} end XSLTProcessor::setSecurityPrefs */