Skip to content

FELIX-6877 maven-bundle-plugin: quote blueprint service header values - #595

Merged
paulrutter merged 3 commits into
apache:masterfrom
holgerfriedrich:pr-quote-import
Nov 15, 2026
Merged

paulrutter merged 3 commits into
apache:masterfrom
holgerfriedrich:pr-quote-import

Conversation

@holgerfriedrich

Copy link
Copy Markdown
Contributor

BlueprintPlugin rebuilt Import-Service / Export-Service with felix-utils Clause.toString(), which only quotes values containing ','. Filters like (ns=http://...) were written unquoted, and bnd >= 7.2, which parses the header again, truncated them at the first '='.

Quote every directive and attribute value that is not a plain OSGi "extended" value. Extend BlueprintComponentTest to parse Import-Service with bnd's OSGiHeader and check the complete namespace filters.

https://issues.apache.org/jira/browse/FELIX-6877

BlueprintPlugin rebuilt Import-Service / Export-Service with felix-utils
Clause.toString(), which only quotes values containing ','. Filters like
(ns=http://...) were written unquoted, and bnd >= 7.2, which parses the
header again, truncated them at the first '='.

Quote every directive and attribute value that is not a plain OSGi
"extended" value. Extend BlueprintComponentTest to parse Import-Service
with bnd's OSGiHeader and check the complete namespace filters.

Signed-off-by: Holger Friedrich <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@paulrutter

paulrutter commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the fix. One blocker:

Backslashes are doubled on round trip. appendValue writes \ as \\, but bnd (checked with bndlib 7.4.0) only unescapes \" when it parses a quoted value. It does not turn \\ back into \.

A filter such as (pid=a\(b) is therefore written and read back like this:

written:    filter="(pid=a\\(b)"
read back:  (pid=a\\(b)

That is a different and invalid filter. Before this PR, backslashes passed through unchanged, so this is a regression for any value with an LDAP-escaped character (\(, \), \*, \\).

Suggested fix: in appendValue, escape only " and leave \ as is:

if ( c == '"' )
{
    sb.append( '\\' );
}
sb.append( c );

Please also add a test with a backslash in a filter.

Minor, not blocking: the new assertions only run for mode == "service", so the generic mode is not covered.

Replace appendValue, which doubled backslashes, with bnd's
Attrs/OSGiHeader.quote. Parse a configured Import-Service/Export-Service
with bnd so single quotes and \" escapes are kept.

Also quote generic mode values, fix the filter for a reference with
both filter and component-name, and add tests incl. generic mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Holger Friedrich <[email protected]>
@holgerfriedrich

Copy link
Copy Markdown
Contributor Author

Thanks, you were right about the backslashes. Fixed in the new commit: values are now quoted with bnd's OSGiHeader.quote, so bnd reads them back unchanged.

Tests: the new BlueprintPluginTest covers backslashes, quotes and generic mode, and BlueprintComponentTest now checks the namespace filters in generic mode too.

Signed-off-by: Holger Friedrich <[email protected]>
@paulrutter

Copy link
Copy Markdown
Contributor

Lgtm

@paulrutter
paulrutter merged commit 9a09c67 into apache:master Nov 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants