def METHOD_NAME(value: bytes) -> bytes:
    fragments = bytearray(value).split(b'\xff')
    if len(fragments) > 1 and not fragments[-1]:
        raise ValueError('string ended unsafe')
    for f in fragments[1:]:
        if (not f) or (f[0] >= 0xE0):
            raise ValueError('invalid sync-safe string')
        if f[0] == 0x00:
            del f[0]
    return bytes(bytearray(b'\xff').join(fragments))