* Refactor bug-related url construction
* Add captcha url (unused, yet) * The second argument to `call/input-url' can be a one-argument function since the call doesn't send it any headers. Still needs to be done: check the HTTP response for an error status, and make it fail as a result (currently it just assumes that any response is fine, which can change in case of a captcha failure). Then, add a captcha challenge if one is found, otherwise ignore.
This commit is contained in:
parent
b43e956c7b
commit
4276898a67
|
@ -16,8 +16,10 @@
|
||||||
saved-bug-report-titles/ids
|
saved-bug-report-titles/ids
|
||||||
discard-all-saved-bug-reports)
|
discard-all-saved-bug-reports)
|
||||||
|
|
||||||
(define bug-www-server "bugs.racket-lang.org")
|
(define (bug-server-url path)
|
||||||
(define bug-www-server-port 80)
|
(string->url (string-append "http://bugs.racket-lang.org/" path)))
|
||||||
|
(define bug-report-url (bug-server-url "bug-report.cgi"))
|
||||||
|
(define captcha-text-url (bug-server-url "captcha-text"))
|
||||||
|
|
||||||
(preferences:set-default 'drracket:email "" string? #:aliases '(drscheme:email))
|
(preferences:set-default 'drracket:email "" string? #:aliases '(drscheme:email))
|
||||||
(preferences:set-default 'drracket:full-name "" string? #:aliases '(drscheme:full-name))
|
(preferences:set-default 'drracket:full-name "" string? #:aliases '(drscheme:full-name))
|
||||||
|
@ -191,10 +193,6 @@
|
||||||
;; initiates sending the bug report and switches the GUI's mode
|
;; initiates sending the bug report and switches the GUI's mode
|
||||||
(define (send-bug-report)
|
(define (send-bug-report)
|
||||||
(define query (get-query))
|
(define query (get-query))
|
||||||
(define url
|
|
||||||
(string->url (format "http://~a:~a/cgi-bin/bug-report"
|
|
||||||
bug-www-server
|
|
||||||
bug-www-server-port)))
|
|
||||||
(define post-data
|
(define post-data
|
||||||
(parameterize ([current-alist-separator-mode 'amp])
|
(parameterize ([current-alist-separator-mode 'amp])
|
||||||
(string->bytes/utf-8 (alist->form-urlencoded query))))
|
(string->bytes/utf-8 (alist->form-urlencoded query))))
|
||||||
|
@ -208,10 +206,8 @@
|
||||||
(with-handlers ([exn:fail? (λ (x) (channel-put exn-chan x))])
|
(with-handlers ([exn:fail? (λ (x) (channel-put exn-chan x))])
|
||||||
(parameterize ([current-alist-separator-mode 'amp])
|
(parameterize ([current-alist-separator-mode 'amp])
|
||||||
(call/input-url
|
(call/input-url
|
||||||
url
|
bug-report-url
|
||||||
(case-lambda
|
(lambda (x) (post-pure-port x post-data))
|
||||||
[(x) (post-pure-port x post-data)]
|
|
||||||
[(x y) (post-pure-port x post-data y)])
|
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
(define response-text (new html-text%))
|
(define response-text (new html-text%))
|
||||||
(render-html-to-text port response-text #t #f)
|
(render-html-to-text port response-text #t #f)
|
||||||
|
|
|
@ -261,11 +261,13 @@
|
||||||
(define captcha-text
|
(define captcha-text
|
||||||
;; This is currently empty -- help/bug-report.rkt will poll it for
|
;; This is currently empty -- help/bug-report.rkt will poll it for
|
||||||
;; text that is used for a captcha challenge question, and if it's not
|
;; text that is used for a captcha challenge question, and if it's not
|
||||||
;; empty, then it will show that in the dialog. It's intended to be
|
;; empty, then it will show that in an input dialog. It's intended to
|
||||||
;; used in the future if spam bug reports that use drracket (or racket
|
;; be used in the future if spam bug reports that use drracket (or
|
||||||
;; code) directly become a problem. In this case, adding a challenge
|
;; racket code) directly become a problem. In this case, adding a
|
||||||
;; here will make existing installations start asking for an answer.
|
;; challenge here will make existing installations start asking for an
|
||||||
;; (And this could be done with a changes-on-each-build basis, or some
|
;; answer. (And this could be done with a changes-on-each-build
|
||||||
;; script that will create and remember short-lived captcha
|
;; basis, or some script that will create and remember short-lived
|
||||||
;; challenges.)
|
;; captcha challenges.) Note that the text should be a complete text
|
||||||
|
;; for a question, including a "?" and instructions. It is used as is
|
||||||
|
;; in the `message' argument for `get-text-from-user'.
|
||||||
@plain[#:file "captcha-text" #:newline #f]{})
|
@plain[#:file "captcha-text" #:newline #f]{})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user