Skip to content

Commit

Permalink
Attempt to improve OU tree handling of symbols in names with special …
Browse files Browse the repository at this point in the history
…meanings, such as slash and comma
  • Loading branch information
neonbunny committed Dec 6, 2024
1 parent 49d2d97 commit ca34c7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'data' : {
'url' : "{% url "event_tracker:bloodhound-ou-api" %}",
'data' : function (node) {
return { 'id' : node.id };
return { 'id' : decodeURIComponent(node.id) };
}
},
'themes': {
Expand Down Expand Up @@ -97,9 +97,9 @@
}).on('changed.jstree', function (e, data) {
var i, j, r = [];
for(i = 0, j = data.selected.length; i < j; i++) {
r.push(data.instance.get_node(data.selected[i]).text);
r.push(decodeURIComponent(data.instance.get_node(data.selected[i]).text));
}
$('#selected').attr("src", "{% url "event_tracker:bloodhound-node" "dndndn" %}".replace("dndndn", data.node.id.split(",").reverse().join(",")));
$('#selected').attr("src", "{% url "event_tracker:bloodhound-node" "dndndn" %}".replace("dndndn", encodeURIComponent(decodeURIComponent(data.node.id.split(",").reverse().join(",")))));
});
});
</script>
Expand Down
10 changes: 5 additions & 5 deletions event_tracker/views_bloodhound.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ def _get_dn_children(tx, parent):
parent = []

children = tx.run("""
match (n) where reverse(split(n.distinguishedname, ','))[$parent_len] is not null and
reverse(split(n.distinguishedname, ','))[0..$parent_len] = $parent
return distinct reverse(split(n.distinguishedname, ','))[$parent_len] as nodetext,
reverse(split(n.distinguishedname, ','))[0..$node_len] as nodepath,
match (n) where reverse(split(replace(n.distinguishedname, "\\\\,", "%5c%2c"), ','))[$parent_len] is not null and
reverse(split(replace(n.distinguishedname, "\\\\,", "%5c%2c"), ','))[0..$parent_len] = $parent
return distinct reverse(split(replace(n.distinguishedname, "\\\\,", "&comma;"), ','))[$parent_len] as nodetext,
reverse(split(replace(n.distinguishedname, "\\\\,", "%5c%2c"), ','))[0..$node_len] as nodepath,
count(*) as childcount,
not max(size(split(n.distinguishedname, ',')) > $node_len) as isleaf,
not max(size(split(replace(n.distinguishedname, "\\\\,", "%5c%2c"), ',')) > $node_len) as isleaf,
collect(distinct labels(n)) as labs,
true in collect(n.owned) as owned
order by left(nodetext, 3) <> "DC=", isleaf, toLower(split(nodetext, '=')[-1])""", parent=parent, parent_len=len(parent), node_len=len(parent) + 1)
Expand Down

0 comments on commit ca34c7f

Please sign in to comment.