mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
res_geolocation: Address user issues, remove complexity, plug leaks
* Added processing for the 'confidence' element. * Added documentation to some APIs. * removed a lot of complex code related to the very-off-nominal case of needing to process multiple location info sources. * Create a new 'ast_geoloc_eprofile_to_pidf' API that just takes one eprofile instead of a datastore of multiples. * Plugged a huge leak in XML processing that arose from insufficient documentation by the libxml/libxslt authors. * Refactored stylesheets to be more efficient. * Renamed 'profile_action' to 'profile_precedence' to better reflect it's purpose. * Added the config option for 'allow_routing_use' which sets the value of the 'Geolocation-Routing' header. * Removed the GeolocProfileCreate and GeolocProfileDelete dialplan apps. * Changed the GEOLOC_PROFILE dialplan function as follows: * Removed the 'profile' argument. * Automatically create a profile if it doesn't exist. * Delete a profile if 'inheritable' is set to no. * Fixed various bugs and leaks * Updated Asterisk WiKi documentation. ASTERISK-30167 Change-Id: If38c23f26228e96165be161c2f5e849cb8e16fa0
This commit is contained in:
30
main/xml.c
30
main/xml.c
@@ -544,35 +544,45 @@ struct ast_xml_doc *ast_xslt_apply(struct ast_xslt_doc *axslt, struct ast_xml_do
|
||||
{
|
||||
xsltStylesheet *xslt = (xsltStylesheet *)axslt;
|
||||
xmlDoc *xml = (xmlDoc *)axml;
|
||||
xmlDoc *res;
|
||||
xsltTransformContextPtr ctxt;
|
||||
xmlNs *ns;
|
||||
xmlDoc *res;
|
||||
int options = XSLT_PARSE_OPTIONS;
|
||||
|
||||
/*
|
||||
* Normally we could just call xsltApplyStylesheet() without creating
|
||||
* our own transform context but we need to pass parameters to it
|
||||
* that have namespace prefixes and that's not supported. Instead
|
||||
* we have to create a transform context, iterate over the namespace
|
||||
* declarations in the stylesheet (not the incoming xml document),
|
||||
* and add them to the transform context's xpath context.
|
||||
* our own transform context but passing parameters to it that have
|
||||
* namespace prefixes isn't supported. Instead we have to create a
|
||||
* transform context, iterate over the namespace declarations in the
|
||||
* stylesheet (not the incoming xml document), add them to the
|
||||
* transform context's xpath context, and call xsltApplyStylesheetUser.
|
||||
*
|
||||
* Since this is a bit involved and libxslt apparently doesn't completely
|
||||
* clean up after itself in this situation, we'll only do that dance
|
||||
* if there are parameters passed in. Otherwise we just call the simpler
|
||||
* xsltApplyStylesheet.
|
||||
*
|
||||
* The alternative would be to pass the parameters with namespaces
|
||||
* as text strings but that's not intuitive and results in much
|
||||
* slower performance than adding the namespaces here.
|
||||
*/
|
||||
|
||||
if (!params) {
|
||||
res = xsltApplyStylesheet(xslt, xml, params);
|
||||
return (struct ast_xml_doc *)res;
|
||||
}
|
||||
|
||||
ctxt = xsltNewTransformContext(xslt, xml);
|
||||
xsltSetCtxtParseOptions(ctxt, options);
|
||||
|
||||
for (ns = xslt->doc->children->nsDef; ns; ns = ns->next) {
|
||||
if (xmlXPathRegisterNs(ctxt->xpathCtxt, ns->prefix, ns->href) != 0) {
|
||||
xmlXPathFreeContext(ctxt->xpathCtxt);
|
||||
xsltFreeTransformContext(ctxt);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
res = xsltApplyStylesheetUser(xslt, xml, params, NULL, NULL, ctxt);
|
||||
xmlXPathFreeContext(ctxt->xpathCtxt);
|
||||
ctxt->xpathCtxt = NULL;
|
||||
xsltFreeTransformContext(ctxt);
|
||||
|
||||
return (struct ast_xml_doc *)res;
|
||||
}
|
||||
|
Reference in New Issue
Block a user