From 74eec87860ed60d85a34e8b0f133d9f96fb3181c Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Fri, 3 Aug 2018 00:46:17 +0200
Subject: [PATCH] Improved handling of abbreviated URLs.
- There was already an explicit code path for something like 'wwww.google.com/' but that code path ended up with the protocol type unset and the port set to 0. Now the protocol defaults to HTTP and the port defaults to 80.
- There was no provision for something like http://www.google.com', rather it was just assumed that the slash after the hostname is always found. Now there's a check if the slash is actually found, and if it isn't found then an empty path is explicitly used.
---
ip65/url.s | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/ip65/url.s b/ip65/url.s
index a92dd18..9e162ff 100644
--- a/ip65/url.s
+++ b/ip65/url.s
@@ -52,10 +52,11 @@ selector_buffer = output_buffer
; url_selector= address of selector part of URL
url_parse:
stax url_string
- ldy #0
+ ldy #url_type_http
sty url_type
+ ldy #80
sty url_port
- sty url_port+1
+ ldy #0
sty url_resource_type
jsr skip_to_hostname
@@ -71,21 +72,15 @@ url_parse:
cmp #'G'
beq @gopher
cmp #'h'
- beq @http
+ beq @protocol_set
cmp #'H'
- beq @http
+ beq @protocol_set
@exit_with_error:
lda #IP65_ERROR_MALFORMED_URL
sta ip65_error
@exit_with_sec:
sec
rts
-@http:
- lda #url_type_http
- sta url_type
- lda #80
- sta url_port
- jmp @protocol_set
@gopher:
lda #url_type_gopher
sta url_type
@@ -123,7 +118,10 @@ lda #url_type_gopher
; skip over next slash
ldax #slash
jsr parser_skip_next
- ; AX now pointing at selector
+ bcc :+
+ ; No slash at all after hostname -> empty selector
+ ldax #zero
+: ; AX now pointing at selector
stax ptr1
ldax #selector_buffer
stax ptr2
@@ -252,7 +250,9 @@ http_preamble:
colon_slash_slash:
.byte ":/"
slash:
- .byte "/",0
+ .byte "/"
+zero:
+ .byte 0
colon:
.byte ":",0