summaryrefslogtreecommitdiff
path: root/module/web/uri.scm
AgeCommit message (Collapse)AuthorFilesLines
2025-03-02Allow trailing "." in urlsDale P. Smith1-7/+10
Fixes https://debbugs.gnu.org/53201 * module/web/uri.scm (valid-host?): Allow trailing "." in URLs * test-suite/tests/web-uri.test: Add tests for trailing "."
2021-01-12Add call-with-input-bytevector, call-with-output-bytevectorAndy Wingo1-48/+6
* module/ice-9/binary-ports.scm (call-with-input-bytevector): (call-with-output-bytevector): New functions. * module/ice-9/iconv.scm: Remove superfluous copies of call-with-output-string* and call-with-output-bytevector*, now that the former closes the port and the latter exists. (call-with-encoded-output-string): Adapt. * module/web/uri.scm: Use (ice-9 iconv) instead of local bytevector/string conversion procedures.
2020-06-18web: Accept URI host names consisting only of hex digits.Ludovic Courtès1-2/+2
Fixes <https://bugs.gnu.org/40582>. Reported by Julien Lepiller <julien@lepiller.eu>. Previously, a host part consisting of hex digits would be mistaken as an IPv6 address and rejected by 'valid-host?'. * module/web/uri.scm (ipv6-regexp): Add colon. * test-suite/tests/web-uri.test ("string->uri")["xyz://abc/x/y/z"]: New test. * NEWS: Update.
2019-08-02Merge from stable-2.2Andy Wingo1-10/+21
2019-06-04Make URI handling locale independent.Timothy Sample1-10/+21
Fixes <https://bugs.gnu.org/35785>. * module/web/uri.scm (digits, hex-digits, letters): New variables. (ipv4-regexp, ipv6-regexp, domain-label-regexp, top-label-regexp, userinfo-pat, host-pat, ipv6-host-pat, port-pat, scheme-pat): Explicitly list each character instead of using character ranges. * test-suite/tests/web-uri.test: Add corresponding tests. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2017-05-22Remove all deprecated codeAndy Wingo1-8/+1
* module/ice-9/debug.scm: * module/ice-9/mapping.scm: * module/ice-9/syncase.scm: Delete these deprecated files. * module/Makefile.am: Remove deleted files. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/backtrace.c: * libguile/goops.c: * libguile/numbers.c: * libguile/socket.c: * libguile/srfi-13.c: * module/ice-9/deprecated.scm: * module/ice-9/format.scm: * module/oop/goops.scm: * module/statprof.scm: * module/texinfo/reflection.scm: * module/web/client.scm: * module/web/uri.scm: Remove deprecated code.
2017-05-21web: add support for URI-referenceAndy Wingo1-29/+123
Based on a patch by Daniel Hartwig <mandyke@gmail.com>. * NEWS: Update. * doc/ref/web.texi (URIs): Fragments are properly part of a URI, so remove the incorrect note. Add documentation on URI subtypes. * module/web/uri.scm (uri-reference?): New base type predicate. (uri?, relative-ref?): Specific predicates. (validate-uri-reference): Strict validation. (validate-uri, validate-relative-ref): Specific validators. (build-uri-reference, build-relative-ref): New constructors. (string->uri-reference): Rename from string->uri. (string->uri, string->relative-ref): Specific constructors. (uri->string): Add #:include-fragment? keyword argument. * module/web/http.scm (parse-request-uri): Use `build-uri-reference', and result is a URI-reference, not URI, object. No longer infer an absent `uri-scheme' is `http'. (write-uri): Just use `uri->string'. (declare-uri-header!): Remove unused function. (declare-uri-reference-header!): Update. Rename from `declare-relative-uri-header!'. * test-suite/tests/web-uri.test ("build-uri-reference"): ("string->uri-reference"): Add. ("uri->string"): Also tests for relative-refs. * test-suite/tests/web-http.test ("read-request-line"): ("write-request-line"): Update for no scheme in some URIs. ("entity headers", "request headers"): Content-location, Referer, and Location should also parse relative-URIs. * test-suite/tests/web-request.test ("example-1"): Expect URI-reference with no scheme.
2016-06-20Fix uri-decode behavior for "+"Andy Wingo1-3/+8
* module/web/uri.scm (uri-decode): Add #:decode-plus-to-space? keyword argument. (split-and-decode-uri-path): Don't decode plus to space. * doc/ref/web.texi (URIs): Update documentation. * test-suite/tests/web-uri.test ("decode"): Add tests. * NEWS: Add entry. Based on a patch by Brent <brent@tomski.co.za>.
2014-11-01web: Location header is URI-reference; better URI-reference supportAndy Wingo1-15/+33
* module/web/uri.scm (validate-uri): Add reference? keyword argument, for validating references. (build-uri): Clarify comments to indicate that the result is an absolute URI. (build-uri-reference): New interface, to build URI-references. (string->uri-reference): Rename from string->uri*. Fix fragment parsing to not include the #. (string->uri): Adapt to string->uri-reference name change. * module/web/request.scm (request-absolute-uri): Add default-scheme optional argument. Use it if the request-uri has no scheme, or error. * module/web/http.scm (write-uri): Reflow to use "when". Fix writing of URI-reference instances. (declare-uri-reference-header!): Rename from declare-relative-uri-header!. Use string->uri-reference. ("Location"): Declare as a URI-reference header, as per RFC 7231. * module/web/client.scm (open-socket-for-uri): Handle the case in which there is no URI scheme. * test-suite/tests/web-http.test: * test-suite/tests/web-uri.test: Add tests.
2013-05-02web: uri-encode hexadecimal percent-encoding is now uppercaseAleix Conchillo Flaque1-5/+6
* module/web/uri.scm (uri-encode): the hexadecimal percent-encoding %HH is now uppercased as suggested by RFC3986: "For consistency, URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings." * test-suite/tests/web-uri.test ("encode"): update tests.
2013-03-16minor tweaks to web documentationDaniel Hartwig1-15/+13
* doc/ref/web.texi: Say `World Wide Web'; the hyphenated form is almost never used (c.f. w3.org). General predicate arguments are named `obj'. Fill in arguments omitted from some procedure definitions (e.g. `request-method'). Minor tweaks, such as using en-dash and missing markup as appropriate. Wrap very long deffn lines. * module/web/*.scm: Expand texinfo markup in doc strings. Synchronize with changes in web.texi.
2013-01-22add read-string and read-string! to (ice-9 rdelim)Andy Wingo1-2/+2
* module/ice-9/rdelim.scm (read-string!, read-string): New functions. * test-suite/tests/rdelim.test: Add tests. * doc/ref/api-io.texi: Add docs. * module/ice-9/iconv.scm: * module/rnrs/io/ports.scm: * module/web/uri.scm: Use the new functions.
2012-11-27web client: correctly handle uri-query, etc. in relative URI headersDaniel Hartwig1-10/+20
* module/web/uri.scm (uri-pat): Make scheme part optional. (string->uri*): New private procedure to also parse relative URIs. * module/web/http.scm (declare-relative-uri-header!): Use that.
2012-11-24(web uri): document that uri-port is an integerDaniel Hartwig1-4/+5
* doc/ref/web.texi (URIs): * module/web/uri.scm (build-uri): Document that uri-port is an integer.
2012-11-24syncronize web module docstrings with manualDaniel Hartwig1-30/+43
* doc/ref/web.texi: Fix spacing. Update with a few missing function descriptions. * module/web/client.scm: * module/web/http.scm: * module/web/request.scm: * module/web/server.scm: * module/web/uri.scm: Update docstrings from manual (reworked by Ludovic Courtès).
2012-08-26Fix uri-encoding for strings with no unreserved charsIan Price1-1/+3
* module/web/uri.scm (uri-encode): Change test to check for unreserved chars instead of reserved chars. * test-suite/tests/web-uri.test ("encode"): Add test.
2012-08-26Fix uri-encoding for octets 0-15Ian Price1-0/+2
* module/web/uri.scm (uri-encode): All encoded octets should be of the form % HEXDIGIT HEXDIGIT. * test-suite/tests/web-uri.test ("encode"): Add test.
2012-07-06more uri-related ipv6 fixesAndy Wingo1-8/+14
* module/web/uri.scm (ipv6-regexp): IPv6 numeric addresses do not have brackets. It's only in URIs that they have them. (ipv6-host-pat, authority-regexp, parse-authority): Refactor ipv6 detection to fix a bug with |, and to extract IPv6 hosts from their brackets. This way we can pass the uri-host directly to inet-pton. (uri->string): If the host contains a `:', assume it is ipv6 and add brackets. * test-suite/tests/web-uri.test ("build-uri"): Adapt tests to assume that the address returned by uri-host and passed to build-uri #:host does not have brackets.
2012-07-06enhance IPv6 supportDaniel Hartwig1-2/+2
* module/web/uri.scm (valid-host?): Support dotted-quad notation in IPv6 addresses. (parse-authority): Support IPv6 literals. * test-suite/tests/web-uri.test: Add and fix tests.
2012-07-06support URIs with domain names starting with numbersDaniel Hartwig1-1/+1
* module/web/uri.scm (valid-host?): Fix regexp to support domain names starting with numbers. * test-suite/tests/web-uri.scm: Add tests for above and IP literals.
2012-02-22microoptimizations in (web uri)Andy Wingo1-11/+10
* module/web/uri.scm (valid-host?): Micro-optimizations.
2012-02-21quick fix the quick fixAndy Wingo1-1/+1
2012-02-21quick fix to uri parserAndy Wingo1-3/+3
* module/web/uri.scm: Quick fix to not throw an error on e.g. http://2012.jsconf.us.
2011-12-06allow URIs of the form file:///etc/hostsAndy Wingo1-8/+12
* module/web/uri.scm (parse-authority): Allow empty authorities, so that we accept URIs of the form, file:///etc/hosts. * test-suite/tests/web-uri.test ("string->uri"): Add tests.
2011-02-24web server more assiduous about closing portsAndy Wingo1-40/+59
* module/web/uri.scm: * module/web/server.scm (call-with-output-string*): (call-with-output-bytevector*): Local procs to output to strings or bytevectors, *and then close the port*. We can't make this change in call-with-output-string because it would be incompatible. * module/web/uri.scm (call-with-encoded-output-string, decode-string) (uri-decode) * module/web/server.scm (call-with-encoded-output-string): Use the new helpers.
2011-02-18core modules use (ice-9 binary-ports) instead of (rnrs io ports)Andy Wingo1-1/+1
* module/language/assembly/compile-bytecode.scm: * module/language/elisp/lexer.scm: * module/web/request.scm: * module/web/response.scm: * module/web/server.scm: * module/web/uri.scm: Use ice-9 binary-ports.
2011-01-07uri-encode fast pathAndy Wingo1-16/+18
* module/web/uri.scm (uri-encode): Add a fast-path for the common case in which the string does not contain any reserved characters.
2011-01-07uri-decode #:encoding, not #:charsetAndy Wingo1-17/+17
* module/web/uri.scm (call-with-encoded-output-string, encode-string) (decode-string, uri-decode, uri-encode): Change all instances of "charset" to "encoding", as variables and arguments.
2011-01-07rename string->uri and uri->string.Andy Wingo1-3/+3
* module/web/uri.scm (string->uri, uri->string): Rename from parse-uri and unparse-uri. * test-suite/tests/web-uri.test: * module/web/http.scm: All callers changed.
2010-12-16document (web uri), and simplify uri-encodeAndy Wingo1-33/+58
* module/web/uri.scm: Add docstrings. (uri-encode): Simplify. Not sure what I was thinking before.
2010-12-12fix testing code in web/serverAndy Wingo1-3/+1
* module/web/server.scm (call-with-encoded-output-string): Fix some code I accidentally left in while testing. Re-tested the difference in speed; pleasantly surprised. * module/web/uri.scm: Make the same change here.
2010-12-11(web uri) can uri-decode non-utf-8 payloadsAndy Wingo1-11/+38
* module/web/uri.scm (call-with-encoded-output-string, encode-string): Copy from server.scm (decode-string): Copy from tekuti. (uri-decode): The #:charset arg is a string, like port-encoding. Support other charsets. (uri-encode): Charset is a string. Other encodings still not nicely supported. Hmm.
2010-11-12unparse-uri avoids serializing e.g. :80 in http:// urisAndy Wingo1-3/+16
* module/web/uri.scm (declare-default-port!): New function, declares a default port for a scheme. Predeclare default ports for http and https. (unparse-uri): If the port is the default port for the given scheme, don't serialize the port part of the URI.
2010-11-04URI parsing errors throw to `uri-error'Andy Wingo1-10/+14
* module/web/uri.scm (uri-error): New proc, throws to 'uri-error. (validate-uri, uri-decode, uri-encode): Use uri-error. * test-suite/tests/web-uri.test: Update for uri-error.
2010-10-17web/uri: reimplement for rfc 3986, add testsAndy Wingo1-169/+282
* module/web/uri.scm: Reimplement for RFC 3986. * module/Makefile.am: Add to build. * test-suite/Makefile.am: * test-suite/tests/web-uri.test: Add tests.
2010-10-17import uri.scm from tekuti, from guile-wwwAndy Wingo1-0/+187