From b063cac571202757ec25f2c6e2a772684b88d4ae Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Tue, 5 May 2020 11:56:54 -0400 Subject: Added input handling with escaping, all untested. --- render.f90 | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'render.f90') diff --git a/render.f90 b/render.f90 index b3b1c32..405fff9 100644 --- a/render.f90 +++ b/render.f90 @@ -275,4 +275,46 @@ contains end subroutine render_link + function handle_input(r, url, unit_number) + use escaper + implicit none + + class(renderer)::r + character(*), intent(inout)::url + integer, intent(in)::unit_number + + logical::handle_input + + character(1024)::response_line + character(256)::answer + integer::question_index + + rewind(unit_number) + + read(unit_number, '(A1024)') response_line + question_index = 3 + do while(response_line(question_index:question_index) == " " .or. & + response_line(question_index:question_index) == char(9)) + + question_index = question_index + 1 + + end do + + handle_input = r%request_input(response_line(question_index:len_trim(response_line)), & + answer) + + if(handle_input) then + question_index = index(url, "?") + if(question_index < 1) then + url = trim(url)//"?" + question_index = len_trim(url) + end if + + call escape_string(answer) + + url = url(1:question_index)//answer + end if + + end function handle_input + end module render -- cgit v1.2.3