From 47c222c945f2758affe828472e711cff8e1290ee Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Fri, 27 Feb 2015 15:44:15 +0000 Subject: [PATCH] Refuse to accept json file with version != 1 --- app/models/asciicast_params.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/asciicast_params.rb b/app/models/asciicast_params.rb index 3c697cf..7b6a5a1 100644 --- a/app/models/asciicast_params.rb +++ b/app/models/asciicast_params.rb @@ -40,6 +40,12 @@ class AsciicastParams def self.from_format_1_request(asciicast_file, username, token, user_agent) asciicast = Oj.sc_parse(AsciicastHandler.new, asciicast_file) + version = asciicast['version'] + + if version != 1 + raise "unsupported asciicast format version: #{version}" + end + env = asciicast['env'] { @@ -53,12 +59,12 @@ class AsciicastParams title: asciicast['title'], user: User.for_api_token!(token, username), user_agent: user_agent, - version: 1, + version: version, } end class AsciicastHandler < ::Oj::ScHandler - META_ATTRIBUTES = %w[width height duration command title env SHELL TERM] + META_ATTRIBUTES = %w[version width height duration command title env SHELL TERM] def hash_start {}