From 959aa693f357888aa77ff17378ab03ac0a082e00 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sun, 25 Sep 2016 23:06:09 +0800 Subject: [PATCH] ok, i guess this is ready --- app/controllers/hacks_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index 42bafd6f..1abe3e60 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -1,16 +1,18 @@ -# bad code that should be seriously checked over before entering one of the -# other prim and proper files in the nice section of this repo +# bad code that should be checked over before entering one of the +# nice files from the right side of this repo class HacksController < ApplicationController include ActionView::Helpers::TextHelper # string truncate method + # rate limited by rack-attack - currently 5r/s + # TODO: what else can we do to make get_with_redirects safer? def load_url_title authorize :Hack - url = params[:url] # TODO verify!?!?!?! + url = params[:url] response, url = get_with_redirects(url) title = get_encoded_title(response) render json: { success: true, title: title, url: url } rescue StandardError => e - render json: { success: false, error_type: e.class.name, error_message: e.message } + render json: { success: false } end private