Lines 56-63
Link Here
|
56 |
import java.lang.ref.Reference; |
56 |
import java.lang.ref.Reference; |
57 |
import java.lang.ref.SoftReference; |
57 |
import java.lang.ref.SoftReference; |
58 |
import java.lang.reflect.Method; |
58 |
import java.lang.reflect.Method; |
|
|
59 |
import java.net.MalformedURLException; |
59 |
import java.net.URL; |
60 |
import java.net.URL; |
60 |
import java.net.URLClassLoader; |
61 |
import java.net.URLClassLoader; |
|
|
62 |
import java.nio.ByteBuffer; |
63 |
import java.nio.CharBuffer; |
64 |
import java.nio.charset.CharacterCodingException; |
65 |
import java.nio.charset.Charset; |
61 |
import java.security.AllPermission; |
66 |
import java.security.AllPermission; |
62 |
import java.security.CodeSource; |
67 |
import java.security.CodeSource; |
63 |
import java.security.PermissionCollection; |
68 |
import java.security.PermissionCollection; |
Lines 80-85
Link Here
|
80 |
import org.openide.modules.InstalledFileLocator; |
85 |
import org.openide.modules.InstalledFileLocator; |
81 |
import org.openide.modules.ModuleInfo; |
86 |
import org.openide.modules.ModuleInfo; |
82 |
import org.openide.util.ChangeSupport; |
87 |
import org.openide.util.ChangeSupport; |
|
|
88 |
import org.openide.util.Exceptions; |
83 |
import org.openide.util.Lookup; |
89 |
import org.openide.util.Lookup; |
84 |
import org.openide.util.LookupEvent; |
90 |
import org.openide.util.LookupEvent; |
85 |
import org.openide.util.LookupListener; |
91 |
import org.openide.util.LookupListener; |
Lines 573-579
Link Here
|
573 |
} |
579 |
} |
574 |
|
580 |
|
575 |
public AllPermissionURLClassLoader(URL[] urls, ClassLoader parent) { |
581 |
public AllPermissionURLClassLoader(URL[] urls, ClassLoader parent) { |
576 |
super(urls, parent); |
582 |
super(sanitize(urls), parent); |
577 |
} |
583 |
} |
578 |
|
584 |
|
579 |
@Override |
585 |
@Override |
Lines 609-614
Link Here
|
609 |
throw e; |
615 |
throw e; |
610 |
} |
616 |
} |
611 |
} |
617 |
} |
|
|
618 |
|
619 |
private static URL sanitize (URL url) { |
620 |
final String surl = url.toExternalForm(); |
621 |
boolean changed = false; |
622 |
final StringBuilder sb = new StringBuilder(); |
623 |
final CharBuffer cb = CharBuffer.allocate(1); |
624 |
final Charset cs = Charset.forName("UTF-8"); |
625 |
try { |
626 |
for (int i=0; i<surl.length(); i++) { |
627 |
char c = surl.charAt(i); |
628 |
if (c <= 127) { |
629 |
sb.append(c); |
630 |
} else { |
631 |
cb.clear(); |
632 |
cb.put(c); |
633 |
cb.flip(); |
634 |
ByteBuffer bb = cs.newEncoder().encode(cb); |
635 |
while (bb.hasRemaining()) { |
636 |
sb.append('%'); //NOI18N |
637 |
sb.append(Integer.toHexString(bb.get() & 0xff )); |
638 |
} |
639 |
changed = true; |
640 |
} |
641 |
} |
642 |
if (changed) { |
643 |
url = new URL(sb.toString()); |
644 |
} |
645 |
} catch (MalformedURLException e) { |
646 |
Exceptions.printStackTrace(e); |
647 |
} catch (CharacterCodingException e) { |
648 |
Exceptions.printStackTrace(e); |
649 |
} |
650 |
return url; |
651 |
} |
652 |
|
653 |
private static URL[] sanitize (final URL... urls) { |
654 |
for (int i=0; i< urls.length; i++) { |
655 |
urls[i] = sanitize(urls[i]); |
656 |
} |
657 |
return urls; |
658 |
} |
659 |
|
660 |
|
612 |
|
661 |
|
613 |
} |
662 |
} |
614 |
|
663 |
|