-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathmuc-room-create.jsp
More file actions
105 lines (91 loc) · 3.77 KB
/
Copy pathmuc-room-create.jsp
File metadata and controls
105 lines (91 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<%@ page contentType="text/html; charset=UTF-8" %>
<%--
-
- Copyright (C) 2004-2008 Jive Software, 2017-2026 Ignite Realtime Foundation. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--%>
<%@ page import="java.util.function.BiFunction" %>
<%@ page import="java.util.regex.Pattern" %>
<%@ page import="java.util.regex.Matcher" %>
<%@ page import="static java.nio.charset.StandardCharsets.UTF_8" %>
<%@ page import="java.net.URLEncoder,java.net.URLDecoder" %>
<%
// OF-31: To select the current conference service automatically on room creation,
// we extract the active service context from the HTTP Referer header. This allows us
// to preserve context from top-level sidebar navigation links (which are statically
// defined in admin-sidebar.xml and do not support dynamic parameters) without having
// to introduce session state or perform intrusive layout changes.
//
// The extraction is done here in the redirector page (muc-room-create.jsp), but the
// validation is kept inside muc-room-edit-form.jsp to preserve clean separation of
// concerns and fallback behaviors.
String referrer = request.getHeader("Referer");
String serviceParam = "";
BiFunction<String, String, String> extractParam = (url, key) -> {
Matcher m = Pattern
.compile("(?:[?&])" + Pattern.quote(key) + "=([^&#]*)")
.matcher(url);
return m.find() ? m.group(1) : null;
};
if (referrer != null) {
String val;
if ((val = extractParam.apply(referrer, "mucname")) != null) {
try {
String decodedVal = URLDecoder.decode(
val,
UTF_8.name()
);
String encodedVal = URLEncoder.encode(
decodedVal,
UTF_8.name()
);
serviceParam = "&mucName=" + encodedVal;
} catch (Exception e) {
// Ignore parsing errors and let validation handle fallbacks
}
} else if ((val = extractParam.apply(referrer, "mucName")) != null) {
try {
String decodedVal = URLDecoder.decode(
val,
UTF_8.name()
);
String encodedVal = URLEncoder.encode(
decodedVal,
UTF_8.name()
);
serviceParam = "&mucName=" + encodedVal;
} catch (Exception e) {
// Ignore parsing errors and let validation handle fallbacks
}
} else if ((val = extractParam.apply(referrer, "roomJID")) != null) {
try {
val = URLDecoder.decode(
val,
UTF_8.name()
);
org.xmpp.packet.JID jid = new org.xmpp.packet.JID(val);
serviceParam = "&mucName=" +
URLEncoder.encode(
jid.getDomain(),
UTF_8.name()
);
} catch (Exception e) {
// Ignore parsing errors and let validation handle fallbacks
}
}
}
response.sendRedirect(
"muc-room-edit-form.jsp?create=true" + serviceParam
);
%>