Project

General

Profile

Bug #401

The Wiki tool: Some questionable code

Added by Carlos Vargas almost 10 years ago. Updated almost 10 years ago.

Status:
Feature implemented
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
07/12/2009
Due date:
% Done:

100%

Estimated time:
Complexity:
Normal
SCRUM pts - complexity:
?

Description

Within the file .../dokeos/main/wiki/diff.inc.php the following function exists:

/** * Split strings on new line
*/
function str_split_on_new_line( $str ) {
$content = array();

if ( strpos( $str, "\r\n" ) != false ) {
$content = explode("\r\n", $str );
}
elseif ( strpos( $str, "\n" ) != false ) {
$content = explode( "\n", $str );
}
elseif ( strpos( $str, "\r" ) != false ) {
$content = explode( "\r", $str );
}
else {
$content[] = $str;
}

return $content;
}

Lines like this:

if ( strpos( $str, "\r\n" ) != false )

look strange. The function strpos returns a number, but:

1. it may return 0 when the "\r\n" is at the beginning of the line;
2. it may return false when "\r\n" was not found.
These both cases are treated in a same way.

Has the function been written intentionally in this way?

History

#1

Updated by Carlos Vargas almost 10 years ago

Actualizado por Ivan Tcholakov hace 6 meses

Comment

In the file .../dokeos/main/wiki/index.php there are two lines like this:

if (strpos($value, "|") != false)

Well, they are strange too.
#2
Actualizado por Yannick Warnier hace alrededor de 1 mes

  • Asignado a deleted * VersiĆ³n prevista changed from 1.8.6 SVN to 1.8.6.2 * Complexity set to Average
#2

Updated by Yannick Warnier almost 10 years ago

  • Target version changed from 1.8.6.2 alpha to 1.8.6.2 beta
#4

Updated by Christian Alberto Fasanando Flores almost 10 years ago

  • Status changed from New to Feature implemented
  • % Done changed from 0 to 100

Also available in: Atom PDF