Ejemplo n.º 1
0
def test_send_file_inline(app):
    with app.test_request_context():
        resp = send_file_inline(data_file("example-balances.csv"))
        assert (resp.headers["Content-Disposition"] ==
                "inline; filename*=UTF-8''example-balances.csv")
        resp = send_file_inline(data_file("example-utf8-🦁.txt"))
        # pylint: disable=line-too-long
        assert (resp.headers["Content-Disposition"] ==
                "inline; filename*=UTF-8''example-utf8-%F0%9F%A6%81.txt")
Ejemplo n.º 2
0
def test_send_file_inline(app):
    with app.test_request_context():
        app.preprocess_request()
        resp = send_file_inline(data_file('example-balances.csv'))
        assert resp.headers['Content-Disposition'] == \
            'inline; filename*=UTF-8\'\'example-balances.csv'
        resp = send_file_inline(data_file('example-utf8-🦁.txt'))
        # pylint: disable=line-too-long
        assert resp.headers['Content-Disposition'] == \
            'inline; filename*=UTF-8\'\'example-utf8-%F0%9F%A6%81.txt'
Ejemplo n.º 3
0
def document():
    """Download a document."""
    filename = request.args.get("filename")
    filenames = [
        document.filename
        for document in g.ledger.all_entries_by_type[Document]
    ]
    import_directories = [
        g.ledger.join_path(d) for d in g.ledger.fava_options["import-dirs"]
    ]
    if filename in filenames:
        return send_file_inline(filename)
    if any(filename.startswith(d) for d in import_directories):
        return send_file_inline(filename)
    return abort(404)
Ejemplo n.º 4
0
def document():
    """Download a document."""
    filename = request.args.get('filename')
    if not any((filename == document.filename
                for document in g.ledger.all_entries_by_type[Document])):
        abort(404)
    return send_file_inline(filename)
Ejemplo n.º 5
0
def document():
    """Download a document."""
    filename = request.args.get('filename')
    if not any((filename == document.filename for document in
                g.ledger.all_entries_by_type[Document])):
        abort(404)
    return send_file_inline(filename)
Ejemplo n.º 6
0
def document() -> Response:
    """Download a document."""
    filename = request.args.get("filename")
    if filename is None:
        return abort(404)
    if is_document_or_import_file(filename, g.ledger):
        return send_file_inline(filename)
    return abort(404)
Ejemplo n.º 7
0
def statement():
    """Download a statement file."""
    entry_hash = request.args.get("entry_hash")
    key = request.args.get("key")
    document_path = g.ledger.statement_path(entry_hash, key)
    return send_file_inline(document_path)
Ejemplo n.º 8
0
def statement():
    """Download a statement file."""
    entry_hash = request.args.get('entry_hash')
    key = request.args.get('key')
    document_path = g.ledger.statement_path(entry_hash, key)
    return send_file_inline(document_path)