Skip to content

formatHtml fails on certain inline SVGs #176

Description

@bh-teufels

Hi,

I ran into a reproducible problem with sourceopt.formatHtml in a TYPO3 v14 project.

Problem

When sourceopt is enabled and sourceopt.formatHtml > 0, some inline SVGs cause a fatal error during HTML formatting.

The visible error is for example:

(1/1) TypeError
preg_replace(): Argument #3 ($subject) must be of type array|string, null given

in /app/vendor/schleuse/dindent/src/Indenter.php line 273 Copy path
        }

        // Restore `<script|style>` & `<!-- -->`
        foreach (array_reverse($this->temporary_replacements_source, true) as $i => $original) {
            $output = preg_replace('/( +)?(<[^>]+>?)?ᐄᐄᐄ' . $i . 'ᐄᐄᐄ/m', preg_replace('/^/m', '\\$1', '$2' . $original['str']) . (!empty($original['lf']) ? "\n$1" : ''), $output);
        }

        return rtrim($output);
    }

at preg_replace('/( +)?(<[^>]+>?)?ᐄᐄᐄ3ᐄᐄᐄ/m', '$1$2$1 .st0 {$1 fill: #035aa9;$1 }$1', null)
in /app/vendor/schleuse/dindent/src/Indenter.php line 273 Copy path
        }

        // Restore `<script|style>` & `<!-- -->`
        foreach (array_reverse($this->temporary_replacements_source, true) as $i => $original) {
            $output = preg_replace('/( +)?(<[^>]+>?)?ᐄᐄᐄ' . $i . 'ᐄᐄᐄ/m', preg_replace('/^/m', '\\$1', '$2' . $original['str']) . (!empty($original['lf']) ? "\n$1" : ''), $output);
        }

        return rtrim($output);
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions