Arc Forumnew | comments | leaders | submit | profquail's commentslogin
3 points by profquail 5588 days ago | link | parent | on: IP Source Domain Bug

Thanks for your detective work fallintothis!

-----


Did anyone notice that the domain for the link isn't parsed properly? If the link is just to an IP address and not a domain, it should print the entire IP address...but it just printed "16.192:8080".

-----

2 points by fallintothis 5595 days ago | link

The offending code from news.arc:

  (def parse-site (url)
    (rev (tokens (cadr (tokens url [in _ #\/ #\?])) #\.)))

  (defmemo sitename (url)
    (and (valid-url url)
         (let toks (parse-site (rem #\space url))
           (if (isa (saferead (car toks)) 'int)
               (tostring (prall toks "" "."))
               (let (t1 t2 t3 . rest) toks  
                 (if (and (~in t3 nil "www")
                          (or (mem t1 multi-tld-countries*) 
                              (mem t2 long-domains*)))
                     (+ t3 "." t2 "." t1)
                     (and t2 (+ t2 "." t1))))))))
The isa test is thrown off by the port number

  arc> (parse-site "http://99.60.16.192:8080/")
  ("192:8080" "16" "60" "99")
  arc> (isa (saferead "192:8080") 'int)
  nil
which leads down the first else-clause of sitename, where

  arc> (and (~in t3 nil "www")
            (or (mem t1 multi-tld-countries*)
                (mem t2 long-domains*)))
  nil
leads to

  arc> (and t2 (+ t2 "." t1))
  "16.192:8080"

-----

2 points by pg 5586 days ago | link

thanks, fixed

-----