diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/docs/RestDocsServlet.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/docs/RestDocsServlet.java index 097de9641..22396bf32 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/docs/RestDocsServlet.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/docs/RestDocsServlet.java @@ -19,6 +19,7 @@ package org.apache.archiva.web.docs; */ import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -56,7 +57,8 @@ public class RestDocsServlet if ( StringUtils.endsWith( path, ".xsd" ) ) { - IOUtils.copy( is, resp.getOutputStream() ); + StringEscapeUtils.escapeXml( resp.getWriter(), IOUtils.toString( is ) ); + //IOUtils.copy( is, resp.getOutputStream() ); return; } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/docs.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/docs.js index 8ecd44021..5389cdd42 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/docs.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/docs.js @@ -25,49 +25,40 @@ define("archiva.docs",["jquery","i18n","jquery.tmpl","bootstrap"], function() { } goToArchivaRestDoc=function(target){ - var mainContent = $("#main-content"); - mainContent.find("#rest_docs_content" ).html(mediumSpinnerImg()); - $.ajax({ - url:"rest-docs/rest-docs-archiva-rest-api/"+target, - type:"get", - dataType: "html", - success: function(data){ - mainContent.html($("#rest_docs").tmpl()); - mainContent.find("#rest_docs_content" ).html(data); - prettyPrint(); - } - }); + goToRestDoc(target,"rest-docs/rest-docs-archiva-rest-api"); } goToArchivaRestUiDoc=function(target){ + + goToRestDoc(target,"rest-docs/rest-docs-archiva-ui"); + } + + goToRedbackRestDoc=function(target){ + + goToRestDoc(target,"rest-docs/rest-docs-redback-rest-api"); + } + + goToRestDoc=function(target,rootPath){ var mainContent = $("#main-content"); mainContent.find("#rest_docs_content" ).html(mediumSpinnerImg()); $.ajax({ - url:"rest-docs/rest-docs-archiva-ui/"+target, + url:rootPath+"/"+target, type:"get", dataType: "html", success: function(data){ mainContent.html($("#rest_docs").tmpl()); - mainContent.find("#rest_docs_content" ).html(data); + if(target.endsWith(".xsd")){ + mainContent.find("#rest_docs_content" ).html(""); + mainContent.find("#xsd_content" ).html(data); + } else { + mainContent.find("#rest_docs_content" ).html(data); + } + prettyPrint(); } }); } - goToRedbackRestDoc=function(target){ - var mainContent = $("#main-content"); - mainContent.find("#rest_docs_content" ).html(mediumSpinnerImg()); - $.ajax({ - url:"rest-docs/rest-docs-redback-rest-api/"+target, - type:"get", - dataType: "html", - success: function(data){ - mainContent.html($("#rest_docs").tmpl()); - mainContent.find("#rest_docs_content" ).html(data); - prettyPrint(); - } - }); - } displayRedbackRestDocs=function(){ window.sammyArchivaApplication.setLocation("#rest-docs-redback-rest-api/index.html"); }