diff --git a/pkg/gmitohtml/convert.go b/pkg/gmitohtml/convert.go
index 3728eb7..704f243 100644
--- a/pkg/gmitohtml/convert.go
+++ b/pkg/gmitohtml/convert.go
@@ -68,20 +68,29 @@ func Convert(page []byte, u string) []byte {
continue
}
- if l >= 7 && bytes.HasPrefix(line, []byte("=> ")) {
- split := bytes.SplitN(line[3:], []byte(" "), 2)
+ if l >= 6 && bytes.HasPrefix(line, []byte("=>")) {
+ splitStart := 2
+ if line[splitStart+1] == ' ' || line[splitStart+1] == '\t' {
+ splitStart++
+ }
+ split := bytes.SplitN(line[splitStart:], []byte(" "), 2)
if len(split) != 2 {
- split = bytes.SplitN(line[3:], []byte("\t"), 2)
+ split = bytes.SplitN(line[splitStart:], []byte("\t"), 2)
}
+
+ linkURL := line[splitStart:]
+ linkLabel := line[splitStart:]
if len(split) == 2 {
- link := append([]byte(``)...)
- link = append(link, split[1]...)
- link = append(link, []byte(``)...)
- result = append(result, link...)
- result = append(result, []byte("
")...)
- continue
+ linkURL = split[0]
+ linkLabel = split[1]
}
+ link := append([]byte(``)...)
+ link = append(link, linkLabel...)
+ link = append(link, []byte(``)...)
+ result = append(result, link...)
+ result = append(result, []byte("
")...)
+ continue
}
heading := 0
diff --git a/pkg/gmitohtml/daemon.go b/pkg/gmitohtml/daemon.go
index e385b3c..ee04f36 100644
--- a/pkg/gmitohtml/daemon.go
+++ b/pkg/gmitohtml/daemon.go
@@ -114,7 +114,7 @@ func fetch(u string) ([]byte, []byte, error) {
}
if !bytes.HasPrefix(header, []byte("2")) {
- return header, []byte(fmt.Sprintf("Unexpected header: %s", header)), nil
+ return header, []byte(fmt.Sprintf(pageHeader+"Server sent unexpected header:
%s", header) + pageFooter), nil
}
if bytes.HasPrefix(header, []byte("20 text/html")) {
@@ -223,13 +223,13 @@ func LastRequestTime() int64 {
}
// SetClientCertificate sets the client certificate to use for a domain.
-func SetClientCertificate(domain string, certificate string, privateKey string) error {
+func SetClientCertificate(domain string, certificate []byte, privateKey []byte) error {
if len(certificate) == 0 || len(privateKey) == 0 {
delete(clientCerts, domain)
return nil
}
- clientCert, err := tls.LoadX509KeyPair(certificate, privateKey)
+ clientCert, err := tls.X509KeyPair(certificate, privateKey)
if err != nil {
return ErrInvalidCertificate
}