7
7
import com .cloudbees .jenkins .plugins .advisor .client .model .Recipient ;
8
8
import com .cloudbees .jenkins .support .SupportPlugin ;
9
9
import hudson .Extension ;
10
+ import hudson .Util ;
10
11
import hudson .model .AsyncPeriodicWork ;
11
12
import hudson .model .TaskListener ;
12
13
import hudson .security .ACL ;
@@ -102,11 +103,12 @@ private File generateBundle() {
102
103
}
103
104
} catch (Exception e ) {
104
105
logError (COULD_NOT_SAVE_SUPPORT_BUNDLE , e );
106
+ var sanitizedMessage = Util .xmlEscape (e .getMessage ());
105
107
updateLastBundleResult (
106
108
config ,
107
109
createTimestampedErrorMessage (
108
110
"<strong>%s</strong><br/><pre><code>%s</code></pre>" ,
109
- COULD_NOT_SAVE_SUPPORT_BUNDLE , e . getMessage () ));
111
+ COULD_NOT_SAVE_SUPPORT_BUNDLE , sanitizedMessage ));
110
112
if (file != null && file .exists () && !file .delete ()) {
111
113
log (Level .WARNING , "Could not delete bundle {0}" + file );
112
114
}
@@ -124,22 +126,24 @@ private void executeInternal(String email, File file, String pluginVersion) {
124
126
if (response .getCode () == 200 ) {
125
127
updateLastBundleResult (config , createTimestampedInfoMessage (BUNDLE_SUCCESSFULLY_UPLOADED ));
126
128
} else {
129
+ var sanitizedMessage = Util .xmlEscape (response .getMessage ());
127
130
updateLastBundleResult (
128
131
config ,
129
132
createTimestampedErrorMessage (
130
133
"<strong>Bundle upload failed</strong><br/>Server response is: <code>%d - %s</code>" ,
131
- response .getCode (), response . getMessage () ));
134
+ response .getCode (), sanitizedMessage ));
132
135
}
133
136
} catch (Exception e ) {
134
137
log (Level .SEVERE , "Issue while uploading file to bundle upload service: " + e .getMessage ());
135
138
log (
136
139
Level .FINEST ,
137
140
"Exception while uploading file to bundle upload service. Cause: "
138
141
+ ExceptionUtils .getStackTrace (e ));
142
+ var sanitizedMessage = Util .xmlEscape (e .getMessage ());
139
143
updateLastBundleResult (
140
144
config ,
141
145
createTimestampedErrorMessage (
142
- "<strong>Bundle upload failed</strong><br/><pre><code>%s</code></pre>" , e . getMessage () ));
146
+ "<strong>Bundle upload failed</strong><br/><pre><code>%s</code></pre>" , sanitizedMessage ));
143
147
} finally {
144
148
if (!file .delete ()) {
145
149
log (Level .WARNING , "Could not delete bundle {0}" + file );
0 commit comments