Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add flag to specify which line feed to use #3567

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions inc/parser/code.php
Expand Up @@ -25,10 +25,16 @@ public function code($text, $language = null, $filename = '') {
$filename = \dokuwiki\Utf8\Clean::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(strpos($INPUT->server->str('HTTP_USER_AGENT'), 'Windows') !== false && $linefeed !== "Unix") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess $linefeed is not defined.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved, the function now has the linefeed as an argument and it defaults to ''

if($linefeed && $linefeed !== 'Unix' || !$linefeed) {
$text = str_replace("\n", "\r\n", $text);
}
}

//if($linefeed == "Windows") {
// $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");
Expand All @@ -47,8 +53,8 @@ public function code($text, $language = null, $filename = '') {
* @param string $language
* @param string $filename
*/
public function file($text, $language = null, $filename = '') {
$this->code($text, $language, $filename);
public function file($text, $language = null, $filename = '', $linefeed = '') {
$this->code($text, $language, $filename, $linefeed);
}

/**
Expand Down