Skip to content

XMLWriter translate Single QUOTE to unwanted ' since PHP8.1 #4654

@alaindev

Description

@alaindev

Single QUOTE translated to unwanted '
Since PHP8.1
htmlspecialchars default parameters switched from
ENT_COMPAT
to
ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401
=> see Changelog

as a result
PhpSpreadsheet Saved with XMLWriter no longger has text with QUOTES but text with '

processing the XLSX file with 'Tiny but Strong' for exemple fails because of wrong syntax due to this new data and semicolon

=> fix is forcing ENT_COMPAT when calling htmlspecialchars in XMLWriter::writeRawData

public function writeRawData($rawTextData)
{
    if (is_array($rawTextData)) {
        $rawTextData = implode("\n", $rawTextData);
    }

    return $this->writeRaw(htmlspecialchars($rawTextData, ENT_COMPAT));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions