diff --git a/collects/help/private/installed-components.ss b/collects/help/private/installed-components.ss index 3bad466756..0cf6c2a807 100644 --- a/collects/help/private/installed-components.ss +++ b/collects/help/private/installed-components.ss @@ -2,7 +2,8 @@ (require (lib "list.ss") (lib "xml.ss" "xml") (lib "getinfo.ss" "setup") - (lib "util.ss" "help" "servlets" "private")) + (lib "uri-codec.ss" "net") + (lib "util.ss" "help" "servlets" "private")) (provide help-desk:installed-components) @@ -95,7 +96,7 @@ " See " `(A ((HREF ,(format "/servlets/doc-anchor.ss?file=~a&caption=Documentation for the ~a collection&name=~a" - (hexify-string (path->string fname)) + (uri-encode (path->string fname)) collection collection))) "the documentation") diff --git a/collects/help/private/manuals.ss b/collects/help/private/manuals.ss index de6ce7a610..e00e2c5a4d 100644 --- a/collects/help/private/manuals.ss +++ b/collects/help/private/manuals.ss @@ -6,6 +6,7 @@ (lib "xml.ss" "xml") (lib "contract.ss") (lib "getinfo.ss" "setup") + (lib "uri-codec.ss" "net") "colldocs.ss" "docpos.ss" "path.ss" @@ -272,7 +273,7 @@ (lambda (collection-doc-file name) (format "
  • ~a collection" ; escape colons and other junk - (hexify-string + (uri-encode (path->string (build-path (car collection-doc-file) (cadr collection-doc-file)))) diff --git a/collects/help/private/standard-urls.ss b/collects/help/private/standard-urls.ss index d314d395fb..7f88cf5cdd 100644 --- a/collects/help/private/standard-urls.ss +++ b/collects/help/private/standard-urls.ss @@ -2,6 +2,7 @@ (require "../servlets/private/util.ss" "internal-hp.ss" + (lib "uri-codec.ss" "net") (lib "contract.ss")) (provide home-page-url) @@ -66,8 +67,8 @@ internal-host internal-port coll - (hexify-string name) - (hexify-string link))) + (uri-encode name) + (uri-encode link))) (define (make-relative-results-url search-string search-type match-type lucky? manuals doc.txt? lang-name) (string-append @@ -88,14 +89,14 @@ "lucky=~a&" "manuals=~a&" "doctxt=~a") - (hexify-string search-string) + (uri-encode search-string) search-type match-type (if lucky? "true" "false") - (hexify-string (format "~s" (map path->bytes manuals))) + (uri-encode (format "~s" (map path->bytes manuals))) (if doc.txt? "true" "false"))]) (if language-name - (string-append start (format "&langname=~a" (hexify-string language-name))) + (string-append start (format "&langname=~a" (uri-encode language-name))) start))) ; sym, string assoc list diff --git a/collects/help/servlets/private/util.ss b/collects/help/servlets/private/util.ss index 88f4f22877..5810d99339 100644 --- a/collects/help/servlets/private/util.ss +++ b/collects/help/servlets/private/util.ss @@ -2,11 +2,11 @@ (require (lib "file.ss") (lib "list.ss") (lib "xml.ss" "xml") + (lib "uri-codec.ss" "net") (lib "string-constant.ss" "string-constants") (lib "contract.ss")) (provide/contract - [hexify-string (string? . -> . string?)] [fold-into-web-path ((listof string?) . -> . string?)]) (provide get-pref/default @@ -76,20 +76,6 @@ (with-handlers ([exn:fail:filesystem? (lambda (x) #f)]) (collection-path "repos-time-stamp")))))) - (define hexifiable '(#\: #\; #\? #\& #\% #\# #\< #\> #\+)) - - ;; hexify-string : string -> string - ;; exploits good properties of utf-8 encoding - ;; that if can-keep? returns true that the byte is - ;; the character index - (define (hexify-string s) - (apply string-append - (map (λ (b) - (cond - [(can-keep? b) (string (integer->char b))] - [else (format "%~X" b)])) - (bytes->list (string->bytes/utf-8 s))))) - ;; can-keep? : byte -> boolean ;; source rfc 2396 (define (can-keep? i) @@ -107,7 +93,7 @@ `(A ((HREF ,(format "/servlets/doc-anchor.ss?file=~a&name=~a&caption=Documentation for the ~a collection" - (hexify-string (path->string coll-file)) + (uri-encode (path->string coll-file)) coll coll))) ,txt) diff --git a/collects/help/servlets/release/license.ss b/collects/help/servlets/release/license.ss index fc4f297bcc..9bf5714c0b 100644 --- a/collects/help/servlets/release/license.ss +++ b/collects/help/servlets/release/license.ss @@ -1,6 +1,7 @@ (module license mzscheme - (require "../private/util.ss") - (require "../private/headelts.ss") + (require "../private/util.ss" + "../private/headelts.ss" + (lib "uri-codec.ss" "net")) (require (lib "servlet.ss" "web-server")) (provide interface-version timeout start) @@ -36,7 +37,7 @@ "under the terms of the LGPL, which in particular means that you must " "release the source code for the modified software. See " (A ((HREF ,(format "/servlets/doc-anchor.ss?name=COPYING.LIB&caption=Copying PLT software&file=~a" - (hexify-string + (uri-encode (path->string (simplify-path (build-path (collection-path "mzlib") 'up 'up "notes" "COPYING.LIB"))))))) diff --git a/collects/help/servlets/results.ss b/collects/help/servlets/results.ss index 2b5dd38aa6..38709b89e0 100644 --- a/collects/help/servlets/results.ss +++ b/collects/help/servlets/results.ss @@ -12,6 +12,7 @@ is stored in a module top-level and that's namespace-specific. (lib "list.ss") (lib "string.ss") (lib "servlet.ss" "web-server") + (lib "uri-codec.ss" "net") "../private/internal-hp.ss" "../private/path.ss" "../private/docpos.ss" @@ -149,8 +150,8 @@ is stored in a module top-level and that's namespace-specific. (let ([maybe-coll (maybe-extract-coll last-header)]) (format no-anchor-format - (hexify-string anchored-path) - (hexify-string (make-caption maybe-coll)) + (uri-encode anchored-path) + (uri-encode (make-caption maybe-coll)) maybe-coll))] [else ; manual, so have absolute path (get-help-url path page-label)]))) @@ -177,10 +178,10 @@ is stored in a module top-level and that's namespace-specific. ; path is absolute pathname (define (make-text-href page-label path) (let* ([maybe-coll (maybe-extract-coll last-header)] - [hex-path (hexify-string (path->string (normalize-path path)))] + [hex-path (uri-encode (path->string (normalize-path path)))] [hex-caption (if (eq? maybe-coll last-header) hex-path - (hexify-string (make-caption maybe-coll)))] + (uri-encode (make-caption maybe-coll)))] [offset (or (and (number? page-label) page-label) 0)]) @@ -188,7 +189,7 @@ is stored in a module top-level and that's namespace-specific. with-anchor-format hex-path hex-caption - (hexify-string maybe-coll) + (uri-encode maybe-coll) offset))) (define (html-entry? path) diff --git a/collects/help/servlets/scheme/how.ss b/collects/help/servlets/scheme/how.ss index 9e9fe97943..529fe62eb1 100644 --- a/collects/help/servlets/scheme/how.ss +++ b/collects/help/servlets/scheme/how.ss @@ -4,6 +4,7 @@ "../../private/manuals.ss" "../private/headelts.ss" "../../private/installed-components.ss" + (lib "uri-codec.ss" "net") (lib "servlet.ss" "web-server")) (provide interface-version timeout start) @@ -95,7 +96,7 @@ (A ((NAME "setup") (VALUE "Setup PLT program"))) (A ((NAME "setup2") (VALUE "setup-plt program"))) (A ((HREF ,(format "/servlets/doc-anchor.ss?file=~a&name=~a&caption=~a" - (hexify-string + (uri-encode (path->string (simplify-path (build-path (collection-path "mzlib") 'up "setup" "doc.txt"))))