View Issue Details

IDProjectCategoryView StatusLast Update
0008238mantisbtfilterspublic2007-12-21 23:16
ReporterMartin Fuchs Assigned ToMartinFuchs  
PrioritynormalSeverityminorReproducibilitysometimes
Status closedResolutionfixed 
Product Version1.1.0a4 
Target Version1.1.0Fixed in Version1.1.0rc3 
Summary0008238: urldecode() error on creating PermaLink
Description

When trying to create a peramenant link using the "PermaLink" feature some times the following error message is display on the opened page:

SYSTEM WARNING: urldecode() expects parameter 1 to be string, array given

I can't yet say on which condition this happens exactly. But it is reproducable at least with one of the stored filters in my local Mantis installation.

Tagspatch
Attached Files
string_api.php.patch (1,449 bytes)   
Index: core/string_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/string_api.php,v
retrieving revision 1.92
diff -u -r1.92 string_api.php
--- core/string_api.php	8 Sep 2007 23:21:01 -0000	1.92
+++ core/string_api.php	23 Oct 2007 13:09:30 -0000
@@ -199,7 +199,6 @@
 	# --------------------
 	# validate the url as part of this site before continuing
 	function string_sanitize_url( $p_url ) {
-
 		$t_url = strip_tags( urldecode( $p_url ) );
 		if ( preg_match( '?http(s)*://?', $t_url ) > 0 ) { 
 			// no embedded addresses
@@ -217,13 +216,20 @@
 			list( $t_path, $t_param ) = split( '\?', $t_url, 2 );
 			if ( $t_param !== "" ) {
 				$t_vals = array();
-				parse_str( $t_param, $t_vals );
+				parse_str( html_entity_decode( $t_param ), $t_vals );
 				$t_param = '';
 				foreach($t_vals as $k => $v) {
 					if ($t_param != '') {
-						$t_param .= '&'; 
+						$t_param .= '&'; 
+					}
+					if ( is_array( $v ) ) {
+						for ( $i = 0, $size = sizeof( $v ); $i < $size; $i++ ) {
+							$t_param .= $k . urlencode('[]') . '=' . urlencode( strip_tags( urldecode( $v[$i] ) ) );
+							$t_param .= ( $i != $size - 1 ) ? '&amp;' : '';
+						}
+					} else {
+						$t_param .= "$k=" . urlencode( strip_tags( urldecode( $v ) ) );
 					}
-					$t_param .= "$k=" . urlencode( strip_tags( urldecode( $v ) ) );
 				}
 				return $t_path . '?' . $t_param;
 			} else {
string_api.php.patch (1,449 bytes)   

Activities

vboctor

vboctor

2007-08-09 03:14

manager   ~0015381

Try using advanced filters and set each of the fields to multiple values, then try. See which field would introduce the problem.

The other option is to check the filter that causes the problem and figure out the fields set in it. This will narrow down the issue.

Martin Fuchs

Martin Fuchs

2007-08-10 17:34

reporter   ~0015405

I can now reproduce the problem with the following steps:

1.) Reset the query filter to default settings.
2.) Create a permalink -> This works without problems.
3.) Filter with "Assigned to" set to [any], [none] or [Myself]. (Yes - also "any", which should be no change of thefilter at all!)
4.) Create a permalink -> This prints "SYSTEM WARNING: urldecode() expects parameter 1 to be string, array given" in red color on the PermaLĂ­nk page.

Sergiodf

Sergiodf

2007-09-11 14:55

reporter   ~0015615

Same problem here.
I can reproduce it by selecting multiple status in advanced filters.

  1. Reset the query filter to default settings.
  2. Create a permalink -> This works without problems.
  3. Switch to Advanced filters.
  4. Create a permalink -> This also works without problems.
  5. Click on "Status:" -> Status list is loaded.
  6. Select some status (I tried some times selecting only one and others times selecting multiple status).
  7. Click on "Apply filter" button. -> Filter is applied and bug list are updated.
  8. Click on "Create Permalink", a new page is opened, same as points 2 and 4 but with a red text "SYSTEM WARNING: urldecode() expects parameter 1 to be string, array given". This text is shown one time for single status filter and two times for 2 or more status filter.
seiji

seiji

2007-10-23 09:10

reporter   ~0015956

I've attached patch.

vboctor

vboctor

2007-11-08 12:00

manager   ~0016118

Martin, can you please validate the patch.

Martin Fuchs

Martin Fuchs

2007-11-08 17:53

reporter   ~0016121

Yes, I can confirm the error messages don't appear any more after applying the patch.

vboctor

vboctor

2007-11-08 21:36

manager   ~0016123

Assigned to Martin to apply to both 1.1.x branch and trunk. Some minor comments:

  • $size -> $t_size.
  • Adjust spaces inside () in some of the code to comply with standard.
  • !== '' -- should be replaced with !is_blank()?
Martin Fuchs

Martin Fuchs

2007-11-09 17:08

reporter   ~0016133

Seiji, thanks for the patch. I just committed it to SVN with Victors proposed changes.

vboctor

vboctor

2007-11-09 19:35

manager   ~0016134

I believe we are ready to resolve this as fixed in 1.1.0rc3, right?

Martin Fuchs

Martin Fuchs

2007-11-10 03:30

reporter   ~0016138

Sure, you can go on and set the status to resolved.