Rename "doc-root" variable to doc-root, fix information leakage in source responder

db4
Slava Pestov 2008-02-24 17:40:58 -06:00
parent 643b3b7dcb
commit 609e5f0cfb
4 changed files with 14 additions and 11 deletions

2
extra/webapps/cgi/cgi.factor Normal file → Executable file
View File

@ -58,7 +58,7 @@ SYMBOL: cgi-root
] with-stream ;
: serve-regular-file ( -- )
cgi-root get "doc-root" [ file-responder ] with-variable ;
cgi-root get doc-root [ file-responder ] with-variable ;
: do-cgi ( name -- )
{

View File

@ -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.
USING: calendar html io io.files kernel math math.parser
http.server.responders http.server.templating namespaces parser
sequences strings assocs hashtables debugger http.mime sorting
html.elements logging ;
IN: webapps.file
SYMBOL: doc-root
: serving-path ( filename -- filename )
"" or "doc-root" get swap path+ ;
"" or doc-root get swap path+ ;
: file-http-date ( filename -- string )
file-modified unix-time>timestamp timestamp>http-string ;
@ -61,7 +62,7 @@ SYMBOL: page
\ run-page DEBUG add-input-logging
: include-page ( filename -- )
"doc-root" get swap path+ run-page ;
serving-path run-page ;
: serve-fhtml ( filename -- )
serving-html
@ -115,14 +116,14 @@ SYMBOL: page
] if ;
: file-responder ( -- )
"doc-root" get [
doc-root get [
"argument" get serve-object
] [
"404 doc-root not set" httpd-error
] if ;
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
! namespace, or inside the responder.
"file" [ file-responder ] add-simple-responder

View File

@ -53,7 +53,7 @@ IN: webapps.fjsc
! the 'fjsc' responder.
"fjsc-resources" [
[
"extra/fjsc/resources/" resource-path "doc-root" set
"extra/fjsc/resources/" resource-path doc-root set
file-responder
] with-scope
] add-simple-responder
@ -62,7 +62,7 @@ IN: webapps.fjsc
! 'termlib'.
"fjsc-repl-resources" [
[
"extra/webapps/fjsc/resources/" resource-path "doc-root" set
"extra/webapps/fjsc/resources/" resource-path doc-root set
file-responder
] with-scope
] add-simple-responder ;

View File

@ -15,14 +15,16 @@ IN: webapps.source
: source-responder ( path mime-type -- )
drop
serving-html
[ dup <file-reader> htmlize-stream ] with-html-stream ;
[
dup file-name swap <file-reader> htmlize-stream
] with-html-stream ;
global [
! Serve up our own source code
"source" [
"argument" get check-source-path [
[
"" resource-path "doc-root" set
"" resource-path doc-root set
[ source-responder ] serve-file-hook set
file-responder
] with-scope