Skip to content

Dancer::Handler miscalculates content length for strings containing wide characters #980

Description

@a-adam

the following code yields wrong octet counts if $content contains wide characters, e.g. "\x{100}":

sub render_response {
      [...]
        $response->header( 'Content-Length' => length($content) )
          if !defined $response->header('Content-Length');

... as length() per default operates on character sematics.
suggested fix:

{
    use bytes;
    $response->header( 'Content-Length' => length($content) )
       if !defined $response->header('Content-Length');
}

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