Skip to content

Commit a2d7ac1

Browse files
Lubos KoscoLubos Kosco
authored andcommitted
Missing ../ in path when displaying xml xref
fixes #806
1 parent e7b6023 commit a2d7ac1

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/org/opensolaris/opengrok/analysis/plain/XMLXref.lex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ NameChar = {FileChar}|"."
103103
{File}|{Path}
104104
{
105105
final String path = yytext();
106-
final char separator = StringUtils.isPossiblyJavaClass(path) ? '.' : '/';
106+
final boolean isJavaClass=StringUtils.isPossiblyJavaClass(path);
107+
final char separator = isJavaClass ? '.' : '/';
107108
final String hyperlink =
108109
Util.breadcrumbPath(urlPrefix + "path=", path, separator,
109-
getProjectPostfix(), true);
110+
getProjectPostfix(), isJavaClass);
110111
out.append(hyperlink);
111112
}
112113

test/org/opensolaris/opengrok/analysis/plain/XMLAnalyzerTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,28 @@ public void bug2225() throws IOException {
4848
// Ordinary file names should not have .'s replaced
4949
assertTrue(xref[3].contains("path=README.txt"));
5050
}
51+
52+
@Test
53+
public void bug806() throws IOException {
54+
String xmlText
55+
= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
56+
+ "<server>\n"
57+
+ " <mbean code=\"QuartzBean\" \n"
58+
+ " name=\"user:service=QuartzService,name=QuartzService\">\n"
59+
+ " <depends>jboss.jca:service=DataSourceBinding,name=ServerDS</depends>\n"
60+
+ " <attribute name=\"JndiName\">Quartz</attribute>\n"
61+
+ " <attribute name=\"Properties\">\n"
62+
+ " org.quartz.plugin.jobInitializer.fileNames = ../server/default/conf/scheduler/quartz_jobs.xml\n"
63+
+ " </attribute>\n"
64+
+ " </mbean>\n"
65+
+ "</server>";
66+
StringReader sr = new StringReader(xmlText);
67+
StringWriter sw = new StringWriter();
68+
XMLAnalyzer.writeXref(sr, sw, null, null, null);
69+
String[] xref = sw.toString().split("\n");
70+
// don't remove ../
71+
assertTrue(xref[7].contains("org.quartz.plugin.jobInitializer.fileNames</a> = <a href=\"/source/s?path=../\">..</a>/"));
72+
}
5173

5274
/**
5375
* XML special chars inside a string were not escaped if single quotes

0 commit comments

Comments
 (0)