Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
XWiki
xwiki-commons
Commits
2a5fa25b
Commit
2a5fa25b
authored
Jun 01, 2022
by
Thomas Mortagne
Browse files
XCOMMONS-2448: Multiline value should not be inlined in the XML serializer
parent
97738e5f
Changes
4
Hide whitespace changes
Inline
Side-by-side
xwiki-commons-core/xwiki-commons-filter/xwiki-commons-filter-api/src/test/java/org/xwiki/filter/test/TestFilter.java
View file @
2a5fa25b
...
...
@@ -77,4 +77,8 @@
void
onChildWithDefaultValue
(
@Name
(
"int"
)
@Default
(
"42"
)
int
integer
,
@Name
(
"string"
)
@Default
(
"default value"
)
String
string
,
@Name
(
"color"
)
@Default
(
"#ffffff"
)
Color
color
,
@Name
(
"map"
)
@Default
(
""
)
Map
<
String
,
String
>
map
);
void
beginContainerWithMultilineParameter
(
String
multi
);
void
endContainerWithMultilineParameter
(
String
multi
);
}
xwiki-commons-core/xwiki-commons-filter/xwiki-commons-filter-api/src/test/java/org/xwiki/filter/test/TestFilterImplementation.java
View file @
2a5fa25b
...
...
@@ -108,6 +108,18 @@ public void onChildWithDefaultValue(int integer, String string, Color color, Map
}
@Override
public
void
beginContainerWithMultilineParameter
(
String
multiline
)
{
}
@Override
public
void
endContainerWithMultilineParameter
(
String
multiline
)
{
}
// Reserved names
@Override
...
...
xwiki-commons-core/xwiki-commons-filter/xwiki-commons-filter-xml/src/main/java/org/xwiki/filter/xml/internal/serializer/DefaultXMLSerializer.java
View file @
2a5fa25b
...
...
@@ -142,9 +142,12 @@ private void writeInlineParameters(List<Object> parameters, FilterElementDescrip
if
(
attributeName
!=
null
)
{
if
(
parameterValue
instanceof
String
)
{
this
.
xmlStreamWriter
.
writeAttribute
(
attributeName
,
(
String
)
parameterValue
);
// Multiline attributes are really not easy to read
if
(!((
String
)
parameterValue
).
contains
(
"\n"
))
{
this
.
xmlStreamWriter
.
writeAttribute
(
attributeName
,
(
String
)
parameterValue
);
parameters
.
set
(
filterParameter
.
getIndex
(),
null
);
parameters
.
set
(
filterParameter
.
getIndex
(),
null
);
}
}
else
if
(
XMLUtils
.
isSimpleType
(
typeClass
))
{
this
.
xmlStreamWriter
.
writeAttribute
(
attributeName
,
this
.
converter
.<
String
>
convert
(
String
.
class
,
parameterValue
));
...
...
xwiki-commons-core/xwiki-commons-filter/xwiki-commons-filter-xml/src/test/java/org/xwiki/filter/xml/XMLSerializerFactoryTest.java
View file @
2a5fa25b
...
...
@@ -153,6 +153,13 @@ void containerWithMap() throws Exception
"<containerWithMap><p><_0><entry><string>key</string><int>1</int></entry></_0></p></containerWithMap>"
);
}
@Test
void
containerWithMultilineParameter
()
throws
Exception
{
assertParseAndSerialize
(
"<containerWithMultilineParameter><p><multi>line1\n"
+
"line2</multi></p></containerWithMultilineParameter>"
);
}
@Test
void
customData
()
throws
Exception
{
...
...
Git Mirror User
@gitmirror
mentioned in commit
9a3059a0
·
Jun 02, 2022
mentioned in commit
9a3059a0
mentioned in commit 9a3059a0dd173a7d7e4989987c93a259f09c4bff
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment