Page MenuHomePhabricator

hardcoded path to tidy
Closed, DeclinedPublic

Description

The binary fallback for Tidy (when php Tidy module is not present) is currently hardcoded in function tidyUp in SpecialHTML2Wiki.php. Perhaps move tidy binary path to a variable declared elsewhere and documented on main mw ext page?

if (class_exists('Tidy')) {

      //.... do the needful. truncated for clarity

} else {
    // using Tidy on the command line expects input from STDIN
    // We'll use printf which is more consistent than echo which varies
    // We want something like the following
    //$result =  shell_exec('printf "$content" | tidy');
    $html = $this->mContent;
    // don't need this escaping since we're not using shell_exec
    // $html = str_replace(array('\\', '%'), array('\\\\', '%%'), $html);
    
    $tidy = "/usr/bin/tidy";
    // only by passing the options as a long string worked.
    // also, $this->mTidyErrors will never populate unless we explicitly 
    // trap STDERR
    // 2>&1 1> /dev/null
    $cmd = "$tidy -quiet -indent -ashtml $shellConfig";
    $tidy = '/usr/bin/tidy -quiet -indent -ashtml  --drop-empty-paras 1 --drop-font-tags 1 --enclose-block-text 1 --enclose-text 1 --fix-backslash 1 --fix-bad-comments 1 --fix-uri 1 --hide-comments 1 --merge-divs 1 --merge-spans 1 --repeated-attributes keep-first --show-body-only 1 --show-errors 0 --show-warnings 0 --indent 0 --wrap 120 --tidy-mark 0 --write-back 0';
    // $escaped_command = escapeshellcmd($cmd);
    // echo "executing $escaped_command";
    // $this->mContentTidy = $this->mContent = shell_exec("printf '$html' | $escaped_command");
    $descriptorspec = array(
        0 => array("pipe", "r"), // stdin is a pipe that the child will read from
        1 => array("pipe", "w"), // stdout is a pipe that the child will write to
        2 => array("pipe", "w")  // stderr is a pipe that the child will write to
        // 2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
    );

Event Timeline

Clunty89 raised the priority of this task from to Needs Triage.
Clunty89 updated the task description. (Show Details)
Clunty89 subscribed.

I don't see it hardcoded anymore in Html2Wiki-REL1_26-467e012.tar.gz

# grep -IRi bin/tidy Html2Wiki 
#

@Clunty89: Is this still a problem in 1.26? See previous comment

Pppery subscribed.

T347236: Archive the Html2Wiki extension

And I probably would have closed this as "Resolved" anyway if I had seen it first.