Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
fd821670
Commit
fd821670
authored
Aug 25, 2014
by
Christian Schudt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OF-839 Forwarded extension should not overwrite extension namespaces of the forwarded message.
parent
2743c92c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
Forwarded.java
src/java/org/jivesoftware/openfire/forward/Forwarded.java
+4
-1
ForwardTest.java
...t/java/org/jivesoftware/openfire/forward/ForwardTest.java
+4
-2
No files found.
src/java/org/jivesoftware/openfire/forward/Forwarded.java
View file @
fd821670
...
...
@@ -19,7 +19,10 @@ public class Forwarded extends PacketExtension {
for
(
Object
element
:
copy
.
getElement
().
elements
())
{
if
(
element
instanceof
Element
)
{
Element
el
=
(
Element
)
element
;
el
.
setQName
(
QName
.
get
(
el
.
getName
(),
"jabber:client"
));
// Only set the "jabber:client" namespace if the namespace is empty (otherwise the resulting xml would look like <body xmlns=""/>)
if
(
""
.
equals
(
el
.
getNamespace
().
getStringValue
()))
{
el
.
setQName
(
QName
.
get
(
el
.
getName
(),
"jabber:client"
));
}
}
}
element
.
add
(
copy
.
getElement
());
...
...
src/test/java/org/jivesoftware/openfire/forward/ForwardTest.java
View file @
fd821670
package
org
.
jivesoftware
.
openfire
.
forward
;
import
org.junit.Test
;
import
org.xmpp.forms.DataForm
;
import
org.xmpp.packet.Message
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
...
@@ -15,12 +16,13 @@ public class ForwardTest {
Message
message
=
new
Message
();
message
.
setType
(
Message
.
Type
.
chat
);
message
.
setBody
(
"Tests"
);
message
.
addExtension
(
new
DataForm
(
DataForm
.
Type
.
submit
));
Forwarded
forwarded
=
new
Forwarded
(
message
);
Forwarded
forwarded2
=
new
Forwarded
(
message
);
String
xml1
=
forwarded
.
getElement
().
asXML
();
String
xml2
=
forwarded2
.
getElement
().
asXML
();
assertEquals
(
"<forwarded xmlns=\"urn:xmpp:forward:0\"><message xmlns=\"jabber:client\" type=\"chat\"><body>Tests</body></message></forwarded>"
,
xml1
);
assertEquals
(
"<forwarded xmlns=\"urn:xmpp:forward:0\"><message xmlns=\"jabber:client\" type=\"chat\"><body>Tests</body></message></forwarded>"
,
xml2
);
assertEquals
(
"<forwarded xmlns=\"urn:xmpp:forward:0\"><message xmlns=\"jabber:client\" type=\"chat\"><body>Tests</body><
x xmlns=\"jabber:x:data\" type=\"submit\"/><
/message></forwarded>"
,
xml1
);
assertEquals
(
"<forwarded xmlns=\"urn:xmpp:forward:0\"><message xmlns=\"jabber:client\" type=\"chat\"><body>Tests</body><
x xmlns=\"jabber:x:data\" type=\"submit\"/><
/message></forwarded>"
,
xml2
);
}
}
Write
Preview
Markdown
is supported
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