Skip to content

[inline TODO] RPC utf8 conversion failure should throw error 32701 in /rpc/TXP_RPCServer.php #1051

Description

@petecooper

Background
This issue is part of a project (#1004) to migrate inline TODOs to GitHub issues. If this issue is still relevant, please assign milestone(s) and team member(s) accordingly.

On acceptance as a valid issue, the code should be annotated with a comment pointing back to this issue.

On completion of the issue, the code should be updated to remove the comment and the pointer to the issue.

TODOs and surrounding code
https://github.com/textpattern/textpattern/blob/dev/rpc/TXP_RPCServer.php#L241
https://github.com/textpattern/textpattern/blob/dev/rpc/TXP_RPCServer.php#L250

            switch ($encoding) {
                case 'utf-8':
                    $data = $HTTP_RAW_POST_DATA;
                    break;
                case 'iso-8859-1':
// TODO: if utf8 conversion fails, throw: 32701 ---> parse error. unsupported encoding?
// see: http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
                    // This will fail on parser if utf8_encode is unavailiable.
                    $data = (function_exists('utf8_encode') && is_callable('utf8_encode'))
                        ? utf8_encode($HTTP_RAW_POST_DATA)
                        : $HTTP_RAW_POST_DATA;
                    break;
                default:
// TODO: if utf8 conversion fails, throw: 32701 ---> parse error. unsupported encoding?
                    // This will fail on parser if mb_convert_encoding is unavailiable.
                    $data = (function_exists('mb_convert_encoding') && is_callable('mb_convert_encoding'))
                        ? mb_convert_encoding($HTTP_RAW_POST_DATA, 'utf-8', $encoding)
                        : $HTTP_RAW_POST_DATA;
                    break;
            }
        }
        $this->message = new IXR_Message($data);
        if (!$this->message->parse()) {
            $this->error(-32700, 'parse error. not well formed');
        }

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions