Cant search for patterns containing a forward-slash

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
rosskus
Posts: 8
Joined: Tue Mar 09, 2010 3:12 pm

Cant search for patterns containing a forward-slash

Post by rosskus »

Hey all,

Seems that the use of / as the delimiter in the preg_replace function causes a bug when searching using patterns that also contain a forward-slash. When I search for things like: Gi9/1 (cisco router interace) the search seems to work, but the "highlighting" function (which changes the background color of the searched-for part of the trunkgroup name yellow), causes the graph name to not display (broken HTML) . See my screenshot. The workaround I've come up with is to change the preg delimiter to something less common like `.

For example on line 1330 of graphs.php:

form_selectable_cell("<a class='linkEditMain' href='" . htmlspecialchars("graphs.php?action=graph_edit&id=" . $graph["local_graph_id"]) . "' title='" . htmlspecialchars($graph["title_cache"]) . "'>" . ((get_request_var_request("filter") != "") ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim(htmlspecialchars($graph["title_cache"]), read_config_option("max_title_graph"))) : title_trim(htmlspecialchars($graph["title_cache"]), read_config_option("max_title_graph"))) . "</a>", $graph["local_graph_id"]);


Changing preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i"
to preg_replace("`(" . preg_quote(get_request_var_request("filter")) . ")/`"

fixed the problem for me. Though there are other places this should probably be changed too.


Ross Kusler
Attachments
missing graph names.PNG
missing graph names.PNG (42.54 KiB) Viewed 1996 times
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Cant search for patterns containing a forward-slash

Post by BSOD2600 »

please create a bug and reference this post - http://www.cacti.net/bugs.php
tosage
Cacti User
Posts: 164
Joined: Wed Jul 28, 2010 5:05 am
Location: France

Re: Cant search for patterns containing a forward-slash

Post by tosage »

Hello,

On Cacti 0.8.7i from Ubuntu repository, i have this problem when i configure an user with in this password a slash.
I see the bug is fixed but it fixed too this problem when you have a slash in your password ?

Thanks for reply :)
Cacti Version - 0.8.8a
Plugin Architecture - 3.1
Poller Type - spine
Server Info - Linux
Web Server - Apache/2.2.22 (Ubuntu)
PHP - 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli)
MySQL - 5.5.29-0ubuntu0.12.04.2
RRDTool - 1.4.7
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Cant search for patterns containing a forward-slash

Post by gandalf »

088a code looks like this:

Code: Select all

	if (sizeof($graph_list) > 0) {
		foreach ($graph_list as $graph) {
			/* we're escaping strings here, so no need to escape them on form_selectable_cell */
			$template_name = ((empty($graph["name"])) ? "<em>None</em>" : htmlspecialchars($graph["name"]));
			form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $graph["local_graph_id"]); $i++;
			form_selectable_cell("<a class='linkEditMain' href='" . htmlspecialchars("graphs.php?action=graph_edit&id=" . $graph["local_graph_id"]) . "' title='" . htmlspecialchars($graph["title_cache"]) . "'>" . ((get_request_var_request("filter") != "") ? preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim(htmlspecialchars($graph["title_cache"]), read_config_option("max_title_graph"))) : title_trim(htmlspecialchars($graph["title_cache"]), read_config_option("max_title_graph"))) . "</a>", $graph["local_graph_id"]);
			form_selectable_cell($graph["local_graph_id"], $graph["local_graph_id"]);
			form_selectable_cell(((get_request_var_request("filter") != "") ? preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $template_name) : $template_name), $graph["local_graph_id"]);
			form_selectable_cell($graph["height"] . "x" . $graph["width"], $graph["local_graph_id"]);
			form_checkbox_cell($graph["title_cache"], $graph["local_graph_id"]);
			form_end_row();
		}

		/* put the nav bar on the bottom as well */
		print $nav;
	}else{
		print "<tr><td><em>No Graphs Found</em></td></tr>";
	}
This should fix your problem. Better is to upgrade to 088a
R.
tosage
Cacti User
Posts: 164
Joined: Wed Jul 28, 2010 5:05 am
Location: France

Re: Cant search for patterns containing a forward-slash

Post by tosage »

I would like upgrade to the latest version but it's not available in the ubuntu 12.04 repository :/

Thanks gandalf for your answer !
Cacti Version - 0.8.8a
Plugin Architecture - 3.1
Poller Type - spine
Server Info - Linux
Web Server - Apache/2.2.22 (Ubuntu)
PHP - 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli)
MySQL - 5.5.29-0ubuntu0.12.04.2
RRDTool - 1.4.7
tosage
Cacti User
Posts: 164
Joined: Wed Jul 28, 2010 5:05 am
Location: France

Re: Cant search for patterns containing a forward-slash

Post by tosage »

Gandaf, for your information, this problem also exist in the 0.8.8a version :cry:
I open a bug in your bugzilla !
Cacti Version - 0.8.8a
Plugin Architecture - 3.1
Poller Type - spine
Server Info - Linux
Web Server - Apache/2.2.22 (Ubuntu)
PHP - 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli)
MySQL - 5.5.29-0ubuntu0.12.04.2
RRDTool - 1.4.7
pscudamore
Posts: 4
Joined: Fri Apr 10, 2015 1:17 pm

Re: Cant search for patterns containing a forward-slash

Post by pscudamore »

I am still having this problem with 0.8.8c. Is there a workaround?

05/07/2015 09:15:09 AM - CMDPHP: Poller[0] WARNING: SNMP Get Timeout for Host:'foo.bar.com', and OID:'.1.3.6.1.4.1.3375.2.2.5.2.3.1.7.ltmPoolStatName."/Common/agent2_test_ldap_aaa_pool"'
05/07/2015 09:15:09 AM - CMDPHP: Poller[0] WARNING: SNMP Get Timeout for Host:'foo.bar.com', and OID:'.1.3.6.1.4.1.3375.2.2.5.2.3.1.7.ltmPoolStatName."/Common/agent2_test_ldap_aaa_pool"'

Please help!

Thanks,

Peter
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests