gopher: use url encoding and decoding to work with weird filenames.
parent
4f2a1a2e4e
commit
77f0865689
|
@ -52,7 +52,7 @@ ERROR: not-a-gopher-url url ;
|
||||||
>url dup protocol>> "gopher" = [ not-a-gopher-url ] unless {
|
>url dup protocol>> "gopher" = [ not-a-gopher-url ] unless {
|
||||||
[ host>> ]
|
[ host>> ]
|
||||||
[ port>> 70 or <inet> binary ]
|
[ port>> 70 or <inet> binary ]
|
||||||
[ path>> rest [ "1/" ] when-empty ]
|
[ path>> rest url-encode [ "1/" ] when-empty ]
|
||||||
[ query>> [ assoc>query url-decode "?" glue ] when* ]
|
[ query>> [ assoc>query url-decode "?" glue ] when* ]
|
||||||
} cleave '[
|
} cleave '[
|
||||||
1 minutes input-stream get set-timeout
|
1 minutes input-stream get set-timeout
|
||||||
|
|
|
@ -5,7 +5,7 @@ USING: accessors calendar combinators combinators.short-circuit
|
||||||
formatting fry io io.directories io.encodings.binary
|
formatting fry io io.directories io.encodings.binary
|
||||||
io.encodings.string io.encodings.utf8 io.files io.files.info
|
io.encodings.string io.encodings.utf8 io.files io.files.info
|
||||||
io.files.types io.pathnames io.servers kernel locals math
|
io.files.types io.pathnames io.servers kernel locals math
|
||||||
mime.types sequences splitting strings ;
|
mime.types sequences splitting strings urls.encoding ;
|
||||||
|
|
||||||
IN: gopher.server
|
IN: gopher.server
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ TUPLE: gopher-server < threaded-server
|
||||||
] [
|
] [
|
||||||
path prepend-path
|
path prepend-path
|
||||||
server serving-directory>> ?head drop
|
server serving-directory>> ?head drop
|
||||||
|
url-encode
|
||||||
] bi
|
] bi
|
||||||
server serving-hostname>>
|
server serving-hostname>>
|
||||||
server insecure>>
|
server insecure>>
|
||||||
|
@ -91,7 +92,7 @@ TUPLE: gopher-server < threaded-server
|
||||||
|
|
||||||
: read-gopher-path ( -- path )
|
: read-gopher-path ( -- path )
|
||||||
readln dup [ "\t\r\n" member? ] find drop [ head ] when*
|
readln dup [ "\t\r\n" member? ] find drop [ head ] when*
|
||||||
trim-tail-separators ;
|
trim-tail-separators url-decode ;
|
||||||
|
|
||||||
M: gopher-server handle-client*
|
M: gopher-server handle-client*
|
||||||
dup serving-directory>> read-gopher-path append-path
|
dup serving-directory>> read-gopher-path append-path
|
||||||
|
|
Loading…
Reference in New Issue