diff options
-rw-r--r-- | application/HttpUtils.php | 14 | ||||
-rw-r--r-- | plugins/markdown/markdown.php | 5 | ||||
-rw-r--r-- | tests/HttpUtils/ServerUrlTest.php | 13 |
3 files changed, 29 insertions, 3 deletions
diff --git a/application/HttpUtils.php b/application/HttpUtils.php index e2c1cb47..af7cb371 100644 --- a/application/HttpUtils.php +++ b/application/HttpUtils.php | |||
@@ -106,11 +106,21 @@ function server_url($server) | |||
106 | // Shaarli is served behind a proxy | 106 | // Shaarli is served behind a proxy |
107 | if (isset($server['HTTP_X_FORWARDED_PROTO'])) { | 107 | if (isset($server['HTTP_X_FORWARDED_PROTO'])) { |
108 | // Keep forwarded scheme | 108 | // Keep forwarded scheme |
109 | $scheme = $server['HTTP_X_FORWARDED_PROTO']; | 109 | if (strpos($server['HTTP_X_FORWARDED_PROTO'], ',') !== false) { |
110 | $schemes = explode(',', $server['HTTP_X_FORWARDED_PROTO']); | ||
111 | $scheme = trim($schemes[0]); | ||
112 | } else { | ||
113 | $scheme = $server['HTTP_X_FORWARDED_PROTO']; | ||
114 | } | ||
110 | 115 | ||
111 | if (isset($server['HTTP_X_FORWARDED_PORT'])) { | 116 | if (isset($server['HTTP_X_FORWARDED_PORT'])) { |
112 | // Keep forwarded port | 117 | // Keep forwarded port |
113 | $port = ':'.$server['HTTP_X_FORWARDED_PORT']; | 118 | if (strpos($server['HTTP_X_FORWARDED_PORT'], ',') !== false) { |
119 | $ports = explode(',', $server['HTTP_X_FORWARDED_PORT']); | ||
120 | $port = ':' . trim($ports[0]); | ||
121 | } else { | ||
122 | $port = ':' . $server['HTTP_X_FORWARDED_PORT']; | ||
123 | } | ||
114 | } | 124 | } |
115 | 125 | ||
116 | return $scheme.'://'.$server['SERVER_NAME'].$port; | 126 | return $scheme.'://'.$server['SERVER_NAME'].$port; |
diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php index a45b6574..5a702c7b 100644 --- a/plugins/markdown/markdown.php +++ b/plugins/markdown/markdown.php | |||
@@ -173,7 +173,10 @@ function process_markdown($description) | |||
173 | ->setBreaksEnabled(true) | 173 | ->setBreaksEnabled(true) |
174 | ->text($processedDescription); | 174 | ->text($processedDescription); |
175 | $processedDescription = sanitize_html($processedDescription); | 175 | $processedDescription = sanitize_html($processedDescription); |
176 | $processedDescription = '<div class="markdown">'. $processedDescription . '</div>'; | 176 | |
177 | if(!empty($processedDescription)){ | ||
178 | $processedDescription = '<div class="markdown">'. $processedDescription . '</div>'; | ||
179 | } | ||
177 | 180 | ||
178 | return $processedDescription; | 181 | return $processedDescription; |
179 | } | 182 | } |
diff --git a/tests/HttpUtils/ServerUrlTest.php b/tests/HttpUtils/ServerUrlTest.php index 5096db65..8a55a220 100644 --- a/tests/HttpUtils/ServerUrlTest.php +++ b/tests/HttpUtils/ServerUrlTest.php | |||
@@ -67,6 +67,19 @@ class ServerUrlTest extends PHPUnit_Framework_TestCase | |||
67 | ) | 67 | ) |
68 | ) | 68 | ) |
69 | ); | 69 | ); |
70 | |||
71 | $this->assertEquals( | ||
72 | 'https://host.tld:4974', | ||
73 | server_url( | ||
74 | array( | ||
75 | 'HTTPS' => 'Off', | ||
76 | 'SERVER_NAME' => 'host.tld', | ||
77 | 'SERVER_PORT' => '80', | ||
78 | 'HTTP_X_FORWARDED_PROTO' => 'https, https', | ||
79 | 'HTTP_X_FORWARDED_PORT' => '4974, 80' | ||
80 | ) | ||
81 | ) | ||
82 | ); | ||
70 | } | 83 | } |
71 | 84 | ||
72 | /** | 85 | /** |