changeset 97:c91fc144dc59

CODETOOLS-7901786 report with incorrect URL for xml_schema/nistData/list/string/Schema+Instance
author afedorch
date Tue, 25 Oct 2016 14:31:53 +0300
parents 093cf06849e4
children cf5e4e8aa73b
files src/com/sun/javatest/util/HTMLWriter.java
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/sun/javatest/util/HTMLWriter.java	Tue Oct 25 14:29:46 2016 +0300
+++ b/src/com/sun/javatest/util/HTMLWriter.java	Tue Oct 25 14:31:53 2016 +0300
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import java.io.IOException;
 import java.io.Writer;
 import java.net.URL;
+import java.net.URLEncoder;
 
 /**
  * A class to facilitate writing HTML via a stream.
@@ -338,10 +339,15 @@
     public void writeLink(File file, String body) throws IOException {
         startTag(A);
         StringBuffer sb = new StringBuffer();
-        String path = file.getPath().replace(File.separatorChar, '/');
+        String path = file.getPath();
         if (file.isAbsolute() && !path.startsWith("/"))
             sb.append('/');
-        sb.append(path);
+
+        for (int i = 0; i < path.length(); i++){
+            String pathSymbol = path.charAt(i) == File.separatorChar ? "/" :
+                    URLEncoder.encode(String.valueOf(path.charAt(i)), "UTF-8");
+            sb.append(pathSymbol);
+        }
         writeAttr(HREF, sb.toString());
         write(body);
         endTag(A);