Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 38 additions & 7 deletions lib/cib/cib_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,18 +766,39 @@ cib_process_xpath(const char *op, int options, const char *section,
break;

} else if (pcmk__str_eq(op, PCMK__CIB_REQUEST_QUERY, pcmk__str_none)) {
if (match->type != XML_ELEMENT_NODE
&& pcmk__is_set(options, cib_xpath_address)) {
/* @COMPAT cib_xpath_address is deprecated since 3.0.2
* For a non-element, handle cib_xpath_address with its
* corresponding element.
*/
match = pcmk__xpath_match_element(match);
if (match == NULL) {
continue;
}

} else if (match->type != XML_ELEMENT_NODE) {
xmlNode *match_element = pcmk__xpath_match_element(match);
xmlNode *brief = NULL;

if (match_element == NULL) {
continue;
}

if (options & cib_no_children) {
xmlNode *shallow = pcmk__xe_create(*answer,
(const char *) match->name);

pcmk__xe_copy_attrs(shallow, match, pcmk__xaf_none);
// Create an element with the corresponding element name
brief = pcmk__xe_create(*answer,
(const char *) match_element->name);
pcmk__xe_set(brief, PCMK_XA_ID, pcmk__xe_id(match_element));
pcmk__xml_copy(brief, match);

if (*answer == NULL) {
*answer = shallow;
*answer = brief;
}

} else if (options & cib_xpath_address) {
continue;
}

if (options & cib_xpath_address) {
// @COMPAT cib_xpath_address is deprecated since 3.0.2
char *path = NULL;
xmlNode *parent = match;
Expand Down Expand Up @@ -808,6 +829,16 @@ cib_process_xpath(const char *op, int options, const char *section,
pcmk__xe_set(parent, PCMK_XA_ID, path);
free(path);

} else if (options & cib_no_children) {
xmlNode *shallow = pcmk__xe_create(*answer,
(const char *) match->name);

pcmk__xe_copy_attrs(shallow, match, pcmk__xaf_none);

if (*answer == NULL) {
*answer = shallow;
}

} else if (*answer) {
pcmk__xml_copy(*answer, match);

Expand Down