From ece4159b488ee81a13b9122239c88d82ec1aa59c Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Sat, 27 Sep 2014 14:08:37 +0200
Subject: Send CRLF to Windows UAs for code blocks #863

---
 inc/parser/code.php | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'inc/parser/code.php')

diff --git a/inc/parser/code.php b/inc/parser/code.php
index 00b956c27..2353e0dfa 100644
--- a/inc/parser/code.php
+++ b/inc/parser/code.php
@@ -21,6 +21,11 @@ class Doku_Renderer_code extends Doku_Renderer {
         $filename = utf8_basename($filename);
         $filename = utf8_stripspecials($filename, '_');
 
+        // send CRLF to Windows clients
+        if(strpos($INPUT->server->str('HTTP_USER_AGENT'), 'Windows') !== false) {
+            $text = str_replace("\n", "\r\n", $text);
+        }
+
         if($this->_codeblock == $INPUT->str('codeblock')) {
             header("Content-Type: text/plain; charset=utf-8");
             header("Content-Disposition: attachment; filename=$filename");
-- 
cgit v1.2.3