From 535a635cc69987665b451074fcf1a2200efc2925 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 8 Oct 2012 15:50:49 +0000 Subject: [PATCH] escape xml content git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1395630 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/web/docs/RestDocsServlet.java | 4 +- .../src/main/webapp/js/archiva/docs.js | 43 ++++++++----------- 2 files changed, 20 insertions(+), 27 deletions(-) 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){ - var mainContent = $("#main-content"); - mainContent.find("#rest_docs_content" ).html(mediumSpinnerImg()); - $.ajax({ - url:"rest-docs/rest-docs-archiva-ui/"+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-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-redback-rest-api/"+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(); } }); } + displayRedbackRestDocs=function(){ window.sammyArchivaApplication.setLocation("#rest-docs-redback-rest-api/index.html"); } -- 2.39.5