Giter Club home page Giter Club logo

Comments (3)

modelrailroader avatar modelrailroader commented on September 25, 2024

I just tested Google Chrome additionally to Mozilla Firefox. Both are showing the same behaviour.

from phpmyfaq.

Az-Yamada avatar Az-Yamada commented on September 25, 2024

Hello. Mr. Thorsten

I am using it in the following environment.
・PHP 8.2
・phpMyFAQ 3.2.3
・Environmental settings Language Japanese

After I finish writing an article in Japanese using an editor, when I publish it, the article is only halfway through and is not displayed.

When I investigated,
https://symfony.com/doc/current/html_sanitizer.html#max-input-length

Max Input Length
In order to prevent DoS attacks, by default the HTML sanitizer limits the input length to 20000 characters (as measured by strlen($input)).

In HtmlSanitizer.php, it seems that the number of characters is counted using 'strlen'.
In src/phpMyFAQ/Helper/FaqHelper.php, it is counted by 'Strings::strlen'.
I expect that the problem will probably occur when using multi-byte characters when writing articles.

For now, in my environment, I have fixed it as follows.
Please use this as a reference for solving the problem.

--- FaqHelper.php.org   2023-12-18 10:09:25.675906766 +0900
+++ FaqHelper.php       2023-12-18 14:40:03.257403251 +0900
@@ -241,7 +241,8 @@ class FaqHelper extends Helper
      */
     public function cleanUpContent(string $content): string
     {
-        $contentLength = Strings::strlen($content);
+        $contentLength = strlen($content);
         $htmlSanitizer = new HtmlSanitizer(
             (new HtmlSanitizerConfig())
                 ->withMaxInputLength($contentLength + 1)

from phpmyfaq.

thorsten avatar thorsten commented on September 25, 2024

This is strange, because Strings::strlen() is just a wrapper for strlen() or, if the "mbstring" extension is available, we use mb_strlen() to avoid these multibyte issues.

@modelrailroader Is the fix for you working as well?

from phpmyfaq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.