Skip to content

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

@a-adam

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');
}

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