{"record":{"id":"98bae01d44266b31","repo":"phalcon/cphalcon","slug":"message","errorCode":null,"errorMessage":"{message}","messagePattern":"\\{message\\}","errorType":"exception","errorClass":"Phalcon\\Html\\Exceptions\\FriendlyTitleConversionFailed","httpStatus":null,"severity":"error","filePath":"phalcon/Html/Helper/FriendlyTitle.zep","lineNumber":62,"sourceCode":"     * @param string     $separator\n     * @param bool       $lowercase\n     * @param mixed|null $replace\n     *\n     * @return string\n     * @throws Exception\n     */\n    public function __invoke(\n        string text,\n        string separator = \"-\",\n        bool lowercase = true,\n        var replace = null\n    ) -> string {\n        var ex;\n\n        try {\n            return this->friendly->__invoke(text, separator, lowercase, replace);\n        } catch \\Exception, ex {\n            throw new FriendlyTitleConversionFailed(ex->getMessage());\n        }\n    }\n}\n","sourceCodeStart":44,"sourceCodeEnd":66,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Html/Helper/FriendlyTitle.zep#L44-L66","documentation":"The FriendlyTitle HTML helper converts text into a URL-friendly title (separator handling, lowercasing, regex replacement). Its __invoke wraps that conversion pipeline in a try/catch and rethrows any failure as FriendlyTitleConversionFailed carrying the original message, so conversion-level problems — most commonly invalid UTF-8 bytes fed to the PCRE functions — surface as one dedicated exception type.","triggerScenarios":"Calling the friendlyTitle helper ($this->tag->friendlyTitle($text) or the FriendlyTitle helper via TagFactory) with byte sequences that are not valid UTF-8, which makes the internal preg_replace return null and throw; running the pipeline without the mbstring extension.","commonSituations":"User-submitted or legacy-encoded (ISO-8859-1/Windows-1252) strings used as titles; data imported from spreadsheets or feeds; binary garbage reaching the title helper through unvalidated input.","solutions":["Sanitize input before conversion: $text = mb_convert_encoding($text, 'UTF-8', mb_detect_encoding($text))","Strip invalid sequences: $text = iconv('UTF-8', 'UTF-8//IGNORE', $text)","Ensure the mbstring extension is installed and enabled"],"exampleFix":"// before\n$title = $this->tag->friendlyTitle($article->title); // legacy-encoded bytes\n\n// after\n$title = $this->tag->friendlyTitle(\n    mb_convert_encoding($article->title, 'UTF-8', 'UTF-8')\n);","handlingStrategy":"try-catch","validationCode":"if (!mb_check_encoding($text, 'UTF-8')) {\n    $text = mb_convert_encoding($text, 'UTF-8', 'UTF-8'); // drops invalid sequences\n}\n\n$title = $this->tag->friendlyTitle($text, '-', true);","typeGuard":"function isSafeTitleText(string $text): bool\n{\n    return mb_check_encoding($text, 'UTF-8');\n}","tryCatchPattern":"try {\n    $title = $this->tag->friendlyTitle($text, '-', true);\n} catch (\\Phalcon\\Html\\Exceptions\\FriendlyTitleConversionFailed $e) {\n    // fallback: transliterate/strip, then retry once\n    $title = $this->tag->friendlyTitle(\n        iconv('UTF-8', 'UTF-8//IGNORE', $text), '-', true\n    );\n}","preventionTips":["Validate UTF-8 at the trust boundary (mb_check_encoding) before storing or rendering titles","Convert legacy-encoded data to UTF-8 during import, not at render time","Ensure mbstring is present in all deployment images"],"tags":["phalcon","html","encoding","utf-8","title"],"backgroundTag":"invalid-utf8-encoding","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}