Skip to content

Commit ec034a2

Browse files
committed
LDEV-6165 skip OSGi Export-Package validation for LAR archives
1 parent 3ffbf8a commit ec034a2

4 files changed

Lines changed: 114 additions & 3 deletions

File tree

core/src/main/java/lucee/runtime/osgi/BundleInfo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ public BundleInfo(File file) throws IOException, BundleException {
131131
else if (!StringUtil.isEmpty(exportPackage, true) || !StringUtil.isEmpty(fragementHost, true)) {
132132
valid = true;
133133
}
134-
// has no exportPackage, fine wjhen it has other files than just class files or has no class files
134+
// LAR archive (Lucee mapping archive) — always valid, not a real OSGi bundle
135+
else if (attrs.getValue("mapping-type") != null) {
136+
valid = true;
137+
}
138+
// has no exportPackage, fine when it has other files than just class files or has no class files
135139
// at all
136140
else {
137141
valid = true;

loader/build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<project default="core" basedir="." name="Lucee"
33
xmlns:resolver="antlib:org.apache.maven.resolver.ant">
44

5-
<property name="version" value="6.2.6.4-SNAPSHOT"/>
5+
<property name="version" value="6.2.6.5-SNAPSHOT"/>
66

77
<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
88
<classpath>

loader/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>org.lucee</groupId>
55
<artifactId>lucee</artifactId>
6-
<version>6.2.6.4-SNAPSHOT</version>
6+
<version>6.2.6.5-SNAPSHOT</version>
77
<packaging>jar</packaging>
88

99
<name>Lucee Loader Build</name>

test/tickets/LDEV6165.cfc

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
component extends="org.lucee.cfml.test.LuceeTestCase" labels="mapping,archive" {
2+
3+
variables.testVirtual = "/ldev6165-test";
4+
variables.adminPassword = "";
5+
6+
function beforeAll() {
7+
variables.adminPassword = request.WEBADMINPASSWORD;
8+
variables.oldMappings = GetApplicationSettings().mappings;
9+
// cleanup mapping from previous runs
10+
try {
11+
admin action="removeMapping" type="web" password="#variables.adminPassword#" virtual="#variables.testVirtual#";
12+
} catch ( any e ) {}
13+
}
14+
15+
function afterAll() {
16+
application action="update" mappings=variables.oldMappings;
17+
try {
18+
admin action="removeMapping" type="web" password="#variables.adminPassword#" virtual="#variables.testVirtual#";
19+
} catch ( any e ) {}
20+
}
21+
22+
private function createLarArchive( required string srcDir, required string larFile, boolean addNonCFMLFiles=false ) {
23+
// create mapping pointing to physical source
24+
admin
25+
action="updateMapping"
26+
type="web"
27+
password="#variables.adminPassword#"
28+
virtual="#variables.testVirtual#"
29+
physical="#arguments.srcDir#"
30+
toplevel="true"
31+
archive=""
32+
primary="physical"
33+
trusted="no";
34+
35+
// create an archive (compiles CFML to .class files)
36+
admin
37+
action="createArchive"
38+
type="web"
39+
password="#variables.adminPassword#"
40+
file="#arguments.larFile#"
41+
virtual="#variables.testVirtual#"
42+
addCFMLFiles="false"
43+
addNonCFMLFiles="#arguments.addNonCFMLFiles#";
44+
45+
expect( fileExists( arguments.larFile ) ).toBeTrue( "LAR file should exist" );
46+
47+
// switch mapping to archive-only, no physical
48+
admin
49+
action="updateMapping"
50+
type="web"
51+
password="#variables.adminPassword#"
52+
virtual="#variables.testVirtual#"
53+
physical=""
54+
toplevel="true"
55+
archive="#arguments.larFile#"
56+
primary="archive"
57+
trusted="no";
58+
59+
// remove the physical source so we know it's coming from the archive
60+
directoryDelete( arguments.srcDir, true );
61+
}
62+
63+
function run( testResults, testBox ) {
64+
describe( "LDEV-6165: LAR archive mapping with only compiled CFML", function() {
65+
66+
it( "should resolve pages from a CFML-only LAR archive", function() {
67+
var testDir = getTempDirectory() & "LDEV6165/cfml-only/";
68+
var srcDir = testDir & "src/";
69+
var larFile = testDir & "test.lar";
70+
71+
// cleanup from previous runs
72+
if ( directoryExists( testDir ) ) directoryDelete( testDir, true );
73+
directoryCreate( srcDir, true, true );
74+
75+
// create a simple CFML file — no non-CFML resources
76+
fileWrite( srcDir & "hello.cfm", "<cfset greeting = 'cfml-only'>" );
77+
78+
createLarArchive( srcDir, larFile, false );
79+
80+
// this is where the bug manifests — include from the archive
81+
include "#variables.testVirtual#/hello.cfm";
82+
expect( greeting ).toBe( "cfml-only" );
83+
});
84+
85+
it( "should resolve pages from a LAR archive with mixed content", function() {
86+
var testDir = getTempDirectory() & "LDEV6165/mixed/";
87+
var srcDir = testDir & "src/";
88+
var larFile = testDir & "test.lar";
89+
90+
// cleanup from previous runs
91+
if ( directoryExists( testDir ) ) directoryDelete( testDir, true );
92+
directoryCreate( srcDir, true, true );
93+
94+
// CFML file plus a static resource
95+
fileWrite( srcDir & "hello.cfm", "<cfset greeting = 'mixed-content'>" );
96+
fileWrite( srcDir & "style.css", "body { color: red; }" );
97+
98+
createLarArchive( srcDir, larFile, true );
99+
100+
include "#variables.testVirtual#/hello.cfm";
101+
expect( greeting ).toBe( "mixed-content" );
102+
});
103+
104+
});
105+
}
106+
107+
}

0 commit comments

Comments
 (0)