ソースを参照

Prevent TypeError

The function filter_special_chars does not have to throw a TypeError
when its argument text is null or undefined because (1) it can be argued
that neither of these two contains special characters and (2) it is much
more convenient to have the check in the function in question rather at
its multiple call sites.
master
Lyubomir Marinov 9年前
コミット
e403a68665
2個のファイルの変更4行の追加3行の削除
  1. 1
    2
      modules/RTC/RTCUtils.js
  2. 3
    1
      modules/xmpp/SDPUtil.js

+ 1
- 2
modules/RTC/RTCUtils.js ファイルの表示

@@ -588,8 +588,7 @@ var RTCUtils = {
588 588
                         return attachMediaStream(element, stream);
589 589
                     };
590 590
                     self.getStreamID = function (stream) {
591
-                        var id = SDPUtil.filter_special_chars(stream.label);
592
-                        return id;
591
+                        return SDPUtil.filter_special_chars(stream.label);
593 592
                     };
594 593
                     self.getVideoSrc = function (element) {
595 594
                         if (!element) {

+ 3
- 1
modules/xmpp/SDPUtil.js ファイルの表示

@@ -4,7 +4,9 @@ var RTCBrowserType = require("../RTC/RTCBrowserType");
4 4
 
5 5
 SDPUtil = {
6 6
     filter_special_chars: function (text) {
7
-        return text.replace(/[\\\/\{,\}\+]/g, "");
7
+        // XXX Neither one of the falsy values (e.g. null, undefined, false,
8
+        // "", etc.) "contain" special chars.
9
+        return text ? text.replace(/[\\\/\{,\}\+]/g, "") : text;
8 10
     },
9 11
     iceparams: function (mediadesc, sessiondesc) {
10 12
         var data = null;

読み込み中…
キャンセル
保存