Author: sshafroi
Date: 2009-01-28 12:11:58 +0100 (Wed, 28 Jan 2009)
New Revision: 7176

Modified:
   branches/2.18/core-api/src/main/java/no/sesat/search/result/Boomerang.java
Log:
SEARCH-5144 - ALFA: URL med ?\195?\184 vises ikke i front og logo f?\195?\165r 
da feil treffside 

Punycode url as a safeguard. We will add a punycode directive to do this 
explicit. This should fix broken links to sites containing non ascii 
characters. 



Modified: 
branches/2.18/core-api/src/main/java/no/sesat/search/result/Boomerang.java
===================================================================
--- branches/2.18/core-api/src/main/java/no/sesat/search/result/Boomerang.java  
2009-01-28 10:35:30 UTC (rev 7175)
+++ branches/2.18/core-api/src/main/java/no/sesat/search/result/Boomerang.java  
2009-01-28 11:11:58 UTC (rev 7176)
@@ -1,4 +1,4 @@
-/* Copyright (2005-2007) Schibsted Søk AS
+/* Copyright (2005-2009) Schibsted Søk AS
  * This file is part of SESAT.
  *
  *   SESAT is free software: you can redistribute it and/or modify
@@ -16,6 +16,7 @@
 */
 package no.sesat.search.result;
 
+import java.net.MalformedURLException;
 import java.util.StringTokenizer;
 import no.sesat.search.site.Site;
 import no.sesat.search.site.config.SiteConfiguration;
@@ -74,11 +75,25 @@
         }
 
         // append the original destination url
-        toUrl.append(orgUrl);
+        toUrl.append(punyencode(orgUrl));
 
         return toUrl.toString();
     }
 
+    private static String punyencode(String url) {
+        String host = null;
+        try {
+            host = new java.net.URL(url).getHost();
+        } catch (MalformedURLException ex) {
+            LOG.warn("Invalid url in boomerang: " + url, ex);
+        }
+
+        if (host != null) {
+            url = url.replace(host, java.net.IDN.toASCII(host));
+        }
+        return url;
+    }
+
     // Constructors -------------------------------------------------
 
     // Public --------------------------------------------------------

_______________________________________________
Kernel-commits mailing list
Kernel-commits@sesat.no
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to