Arc Forumnew | comments | leaders | submitlogin
IP Source Domain Bug
5 points by profquail 5585 days ago | 3 comments
I mentioned in a previous thread here on the Arc forum that there was a bug in the way that news.arc handles printing the source domain for story links: http://www.arclanguage.org/item?id=10486

In that case, only the last 2 octets of the IP are printed, along with the port number (in the correct order though).

I was just reading through HN and found it popping up there as well: http://news.ycombinator.com/item?id=811850

In that case, the IP is printed (all 4 octets) in reverse order compared to the link URL



4 points by fallintothis 5585 days ago | link

In the style of my previous response, 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))))))))
In particular,

  (tostring (prall toks "" "."))
will generate a reversed IP because toks is already reversed:

  arc> (= toks (parse-site "http://74.125.95.132/"))
  ("132" "95" "125" "74")
  arc> (isa (saferead (car toks)) 'int)
  t
  arc> (tostring (prall toks "" "."))
  "132.95.125.74"

-----

3 points by profquail 5584 days ago | link

Thanks for your detective work fallintothis!

-----

2 points by pg 5583 days ago | link

oops, fixed

-----