Skip to content

Fix Path Traversal Vulnerability #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from flask.json import jsonify
from flask import request
from werkzeug.utils import safe_join
from flask import send_file
from app.FileDelegate import FileDelegate
from app.TagsDelegate import TagsDelegate
Expand Down Expand Up @@ -46,13 +47,14 @@ def getAll():
@app.route("/search/ByIngredients", methods=['GET'])
def searchByIngredients():
ingredients = request.args['ingredients'].split(',')
recipes=IngredientsDelegate().ingredientsInclude(ingredients)
recipes = IngredientsDelegate().ingredientsInclude(ingredients)
return jsonify(recipes)


@app.route("/search/ByIngredients/all", methods=['GET'])
def searchByIngredientsAll():
ingredients = request.args['ingredients'].split(',')
recipes=IngredientsDelegate().ingredientsIncludeAll(ingredients)
recipes = IngredientsDelegate().ingredientsIncludeAll(ingredients)
return jsonify(recipes)


Expand Down Expand Up @@ -93,9 +95,9 @@ def getIngredients():
ingredients = IngredientsDelegate().getIngredients()
return jsonify(list(ingredients))

@app.route('/download',methods=['GET'])

@app.route('/download', methods=['GET'])
def downloadFile():
filename=request.args['filename']
full_path=os.path.join(os.getcwd(),"pdfs",filename)
filename = request.args['filename']
full_path = safe_join(os.getcwd(), "pdfs", filename)
return send_file(full_path)