Rename "doc-root" variable to doc-root, fix information leakage in source responder
parent
643b3b7dcb
commit
609e5f0cfb
|
@ -58,7 +58,7 @@ SYMBOL: cgi-root
|
||||||
] with-stream ;
|
] with-stream ;
|
||||||
|
|
||||||
: serve-regular-file ( -- )
|
: serve-regular-file ( -- )
|
||||||
cgi-root get "doc-root" [ file-responder ] with-variable ;
|
cgi-root get doc-root [ file-responder ] with-variable ;
|
||||||
|
|
||||||
: do-cgi ( name -- )
|
: do-cgi ( name -- )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
! Copyright (C) 2004, 2007 Slava Pestov.
|
! Copyright (C) 2004, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: calendar html io io.files kernel math math.parser
|
USING: calendar html io io.files kernel math math.parser
|
||||||
http.server.responders http.server.templating namespaces parser
|
http.server.responders http.server.templating namespaces parser
|
||||||
sequences strings assocs hashtables debugger http.mime sorting
|
sequences strings assocs hashtables debugger http.mime sorting
|
||||||
html.elements logging ;
|
html.elements logging ;
|
||||||
|
|
||||||
IN: webapps.file
|
IN: webapps.file
|
||||||
|
|
||||||
|
SYMBOL: doc-root
|
||||||
|
|
||||||
: serving-path ( filename -- filename )
|
: serving-path ( filename -- filename )
|
||||||
"" or "doc-root" get swap path+ ;
|
"" or doc-root get swap path+ ;
|
||||||
|
|
||||||
: file-http-date ( filename -- string )
|
: file-http-date ( filename -- string )
|
||||||
file-modified unix-time>timestamp timestamp>http-string ;
|
file-modified unix-time>timestamp timestamp>http-string ;
|
||||||
|
@ -61,7 +62,7 @@ SYMBOL: page
|
||||||
\ run-page DEBUG add-input-logging
|
\ run-page DEBUG add-input-logging
|
||||||
|
|
||||||
: include-page ( filename -- )
|
: include-page ( filename -- )
|
||||||
"doc-root" get swap path+ run-page ;
|
serving-path run-page ;
|
||||||
|
|
||||||
: serve-fhtml ( filename -- )
|
: serve-fhtml ( filename -- )
|
||||||
serving-html
|
serving-html
|
||||||
|
@ -115,14 +116,14 @@ SYMBOL: page
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: file-responder ( -- )
|
: file-responder ( -- )
|
||||||
"doc-root" get [
|
doc-root get [
|
||||||
"argument" get serve-object
|
"argument" get serve-object
|
||||||
] [
|
] [
|
||||||
"404 doc-root not set" httpd-error
|
"404 doc-root not set" httpd-error
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
global [
|
global [
|
||||||
! Serves files from a directory stored in the "doc-root"
|
! Serves files from a directory stored in the doc-root
|
||||||
! variable. You can set the variable in the global
|
! variable. You can set the variable in the global
|
||||||
! namespace, or inside the responder.
|
! namespace, or inside the responder.
|
||||||
"file" [ file-responder ] add-simple-responder
|
"file" [ file-responder ] add-simple-responder
|
||||||
|
|
|
@ -53,7 +53,7 @@ IN: webapps.fjsc
|
||||||
! the 'fjsc' responder.
|
! the 'fjsc' responder.
|
||||||
"fjsc-resources" [
|
"fjsc-resources" [
|
||||||
[
|
[
|
||||||
"extra/fjsc/resources/" resource-path "doc-root" set
|
"extra/fjsc/resources/" resource-path doc-root set
|
||||||
file-responder
|
file-responder
|
||||||
] with-scope
|
] with-scope
|
||||||
] add-simple-responder
|
] add-simple-responder
|
||||||
|
@ -62,7 +62,7 @@ IN: webapps.fjsc
|
||||||
! 'termlib'.
|
! 'termlib'.
|
||||||
"fjsc-repl-resources" [
|
"fjsc-repl-resources" [
|
||||||
[
|
[
|
||||||
"extra/webapps/fjsc/resources/" resource-path "doc-root" set
|
"extra/webapps/fjsc/resources/" resource-path doc-root set
|
||||||
file-responder
|
file-responder
|
||||||
] with-scope
|
] with-scope
|
||||||
] add-simple-responder ;
|
] add-simple-responder ;
|
||||||
|
|
|
@ -15,14 +15,16 @@ IN: webapps.source
|
||||||
: source-responder ( path mime-type -- )
|
: source-responder ( path mime-type -- )
|
||||||
drop
|
drop
|
||||||
serving-html
|
serving-html
|
||||||
[ dup <file-reader> htmlize-stream ] with-html-stream ;
|
[
|
||||||
|
dup file-name swap <file-reader> htmlize-stream
|
||||||
|
] with-html-stream ;
|
||||||
|
|
||||||
global [
|
global [
|
||||||
! Serve up our own source code
|
! Serve up our own source code
|
||||||
"source" [
|
"source" [
|
||||||
"argument" get check-source-path [
|
"argument" get check-source-path [
|
||||||
[
|
[
|
||||||
"" resource-path "doc-root" set
|
"" resource-path doc-root set
|
||||||
[ source-responder ] serve-file-hook set
|
[ source-responder ] serve-file-hook set
|
||||||
file-responder
|
file-responder
|
||||||
] with-scope
|
] with-scope
|
||||||
|
|
Loading…
Reference in New Issue