Uploaded image for project: 'Blesta Core'
  1. Blesta Core
  2. CORE-4418

Order: Maxmind - Error encoding input as JSON: Malformed UTF-8 characters.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.0
    • Fix Version/s: 5.1.3, 5.2.0-b1
    • Component/s: Plugins
    • Labels:
      None

      Description

      Maxmind calls json_encode to encode data prior to sending it to Maxmind for fraud checks. The problem is that json_encode only supports the UTF8 character set. See https://www.php.net/manual/en/function.json-encode

      I have not tried to reproduce this, but I suspect that any 4-byte characters like Emoji's that are included in the data being encoded, would cause json_encode to fail.

      Here's a partial error:

      (MaxMind\\Exception
      InvalidInputException(code: 0): Error encoding input as JSON: Malformed UTF-8 characters. at /home/user/blesta/vendors/maxmind/web-service-common/src/WebService/Client.php:107)"}

        Activity

        admin Paul Phillips created issue -
        admin Paul Phillips made changes -
        Field Original Value New Value
        Rank Ranked higher
        Hide
        admin Paul Phillips added a comment -

        In a specific use case, the user agent caused the issue, note the special character in the user agent:

        [device] => Array
        (
        [ip_address] => 192.168.0.24
        [user_agent] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5 (Ergänzendes Update)) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15
        )

        Show
        admin Paul Phillips added a comment - In a specific use case, the user agent caused the issue, note the special character in the user agent: [device] => Array ( [ip_address] => 192.168.0.24 [user_agent] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5 (Ergänzendes Update)) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15 )
        jonathan Jonathan Reissmueller made changes -
        Sprint 5.2.0 Sprint 3 [ 140 ]
        jonathan Jonathan Reissmueller made changes -
        Rank Ranked lower
        jonathan Jonathan Reissmueller made changes -
        Assignee Jonathan Reissmueller [ jonathan ]
        jonathan Jonathan Reissmueller made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        jonathan Jonathan Reissmueller made changes -
        Rank Ranked higher
        Hide
        jonathan Jonathan Reissmueller added a comment -

        To reproduce the error I added the following to plugins/order/components/antifraud/maxmind_v2/maxmind_v2.php line 269:

                $_SERVER['HTTP_USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'] . chr(hexdec('0xFE'));
        
        Show
        jonathan Jonathan Reissmueller added a comment - To reproduce the error I added the following to plugins/order/components/antifraud/maxmind_v2/maxmind_v2.php line 269: $_SERVER['HTTP_USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'] . chr(hexdec('0xFE'));
        jonathan Jonathan Reissmueller made changes -
        Remaining Estimate 0 minutes [ 0 ]
        Time Spent 1 hour, 32 minutes [ 5520 ]
        Worklog Id 15163 [ 15163 ]
        jonathan Jonathan Reissmueller made changes -
        Status In Progress [ 3 ] In Review [ 5 ]
        Resolution Fixed [ 1 ]
        jonathan Jonathan Reissmueller made changes -
        Time Spent 1 hour, 32 minutes [ 5520 ] 2 hours, 32 minutes [ 9120 ]
        Worklog Id 15186 [ 15186 ]
        jonathan Jonathan Reissmueller made changes -
        Status In Review [ 5 ] Closed [ 6 ]
        jonathan Jonathan Reissmueller made changes -
        Resolution Fixed [ 1 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        jonathan Jonathan Reissmueller made changes -
        Status Reopened [ 4 ] In Progress [ 3 ]
        jonathan Jonathan Reissmueller made changes -
        Status In Progress [ 3 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            jonathan Jonathan Reissmueller
            Reporter:
            admin Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Fix Release Date:
              24/Aug/21

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 2 hours, 32 minutes
              2h 32m

                Agile