Skip to content
Snippets Groups Projects
  • Jared Hancock's avatar
    f15b893e
    storage: Avoid using `strlen` to count bytes · f15b893e
    Jared Hancock authored
    For PHP installations that have `mbstring.func_overload` enabled (set to a
    value including `2`), the `strlen` function will be overloaded to use the
    `mb_strlen` equivalent. Problematically, the internal encoding of `UTF-8`
    will be applied to all file content, which will count UTF-8 characters
    rather than bytes. This will cause the data to be saved correctly; however,
    the `size` recorded in the %file table will be recorded incorrectly.
    
    This patch allows the backend to report the size of the contents saved with
    the request and provides a failsafe mechanism which will use the mbstring
    equivalent if available, and the mbstring version is coded to use the `8bit`
    as the encoding which will prevent reading characters.
    
    References:
    https://github.com/osTicket/osTicket-1.8/issues/552
    f15b893e
    History
    storage: Avoid using `strlen` to count bytes
    Jared Hancock authored
    For PHP installations that have `mbstring.func_overload` enabled (set to a
    value including `2`), the `strlen` function will be overloaded to use the
    `mb_strlen` equivalent. Problematically, the internal encoding of `UTF-8`
    will be applied to all file content, which will count UTF-8 characters
    rather than bytes. This will cause the data to be saved correctly; however,
    the `size` recorded in the %file table will be recorded incorrectly.
    
    This patch allows the backend to report the size of the contents saved with
    the request and provides a failsafe mechanism which will use the mbstring
    equivalent if available, and the mbstring version is coded to use the `8bit`
    as the encoding which will prevent reading characters.
    
    References:
    https://github.com/osTicket/osTicket-1.8/issues/552