Bug 1275941 - Trim white-space characters from calendar.useragent.extra to avoid redundant spaces in the user-agent string. r=philipp
authorrsx11m <rsx11m.pub@gmail.com>
Thu, 09 Jun 2016 17:47:57 -0500
changeset 25240 bdf682a3f887eebe4511a326b3fe5e6861d0d7ca
parent 25239 c89aaa727a7d3ec8199ecec7834875334bd1b097
child 25241 19210c4ad776bcfa861d985127d8eacbb03d687b
push id1725
push userclokep@gmail.com
push dateMon, 19 Sep 2016 17:35:08 +0000
treeherdercomm-beta@6ead1abf3817 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp
bugs1275941
Bug 1275941 - Trim white-space characters from calendar.useragent.extra to avoid redundant spaces in the user-agent string. r=philipp
calendar/base/src/calCalendarManager.js
--- a/calendar/base/src/calCalendarManager.js
+++ b/calendar/base/src/calCalendarManager.js
@@ -146,17 +146,19 @@ calCalendarManager.prototype = {
                 // been removed. Calendar servers might still want to know what
                 // client is used for access, so add our UA String to each
                 // request.
                 let httpChannel = aSubject.QueryInterface(Components.interfaces.nsIHttpChannel);
                 try {
                     // NOTE: For some reason, this observer call doesn't have
                     // the "cal" namespace defined
                     let ua = httpChannel.getRequestHeader("User-Agent");
-                    let calUAString = Preferences.get("calendar.useragent.extra");
+                    let calUAString = Preferences.get("calendar.useragent.extra", "").trim();
+
+                    // Don't add an empty string or an already included token.
                     if (calUAString && !ua.includes(calUAString)) {
                         // User-Agent is not a mergeable header. We need to
                         // merge the user agent ourselves.
                         httpChannel.setRequestHeader("User-Agent",
                                                      ua + " " + calUAString,
                                                      false);
                     }
                 } catch (e if e.result == Components.results.NS_ERROR_NOT_AVAILABLE) {