diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-11-30 22:38:36 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-11-30 22:38:36 +0300 |
commit | 390cd897b17a79ad00f6c6d86d2289b00b9d3be3 (patch) | |
tree | e802c1e14855ac55ab86161b3e181f66ea2935a7 /plugins/SegmentEditor | |
parent | 63f34d14793881e667344960571e76aa3bf6f509 (diff) |
fix #9306 try to handle a urldecoded segment first when formatting a segment
Diffstat (limited to 'plugins/SegmentEditor')
-rw-r--r-- | plugins/SegmentEditor/SegmentFormatter.php | 9 | ||||
-rw-r--r-- | plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php | 6 |
2 files changed, 13 insertions, 2 deletions
diff --git a/plugins/SegmentEditor/SegmentFormatter.php b/plugins/SegmentEditor/SegmentFormatter.php index 54dcc20c99..19838d46d5 100644 --- a/plugins/SegmentEditor/SegmentFormatter.php +++ b/plugins/SegmentEditor/SegmentFormatter.php @@ -59,8 +59,13 @@ class SegmentFormatter return Piwik::translate('SegmentEditor_DefaultAllVisits'); } - $segment = new SegmentExpression($segmentString); - $expressions = $segment->parseSubExpressions(); + try { + $segment = new SegmentExpression(urldecode($segmentString)); + $expressions = $segment->parseSubExpressions(); + } catch (Exception $e) { + $segment = new SegmentExpression($segmentString); + $expressions = $segment->parseSubExpressions(); + } $readable = ''; foreach ($expressions as $expression) { diff --git a/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php b/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php index bc0f206784..ca37e0775b 100644 --- a/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php +++ b/plugins/SegmentEditor/tests/Integration/SegmentFormatterTest.php @@ -88,6 +88,12 @@ class SegmentFormatterTest extends IntegrationTestCase $this->assertSame('Browser version is not null nor empty', $readable); } + public function test_getHumanReadable_ShouldHandleAUrlDecodedSegment() + { + $readable = $this->formatter->getHumanReadable($segment = 'pageUrl%3D%40piwik%2CvisitId!%3D1', $this->idSite); + $this->assertSame('Page URL contains "piwik" or Visit ID is not "1"', $readable); + } + /** * @expectedException \Exception * @expectedExceptionMessage The segment 'noTexisTinG' does not exist |