Bug 1394078: reject SDP with non-ASCII chars. r=bwc

MozReview-Commit-ID: 3s5gpcDNK4W

--HG--
extra : rebase_source : 4ee35312e76709d587bc87a4760f0481f41ac6e6
This commit is contained in:
Nils Ohlmeier [:drno] 2017-08-25 22:58:25 -07:00
Родитель a4efa141db
Коммит f16dee0822
1 изменённых файлов: 25 добавлений и 24 удалений

Просмотреть файл

@ -848,16 +848,7 @@ class RTCPeerConnection {
return this._havePermission;
}
setLocalDescription(desc, onSucc, onErr) {
return this._auto(onSucc, onErr, () => this._setLocalDescription(desc));
}
async _setLocalDescription({ type, sdp }) {
this._checkClosed();
this._localType = type;
let action = this._actions[type];
_sanityCheckSdp(action, type, sdp) {
if (action === undefined) {
throw new this._win.DOMException(
"Invalid type " + type + " provided to setLocalDescription",
@ -874,6 +865,29 @@ class RTCPeerConnection {
"InvalidParameterError");
}
// The fippo butter finger filter AKA non-ASCII chars
// Note: SDP allows non-ASCII character in the subject (who cares?)
let pos = sdp.search(/[^\u0000-\u007f]/);
if (pos != -1) {
throw new this._win.DOMException(
"SDP contains non ASCII characters at position " + pos,
"InvalidParameterError");
}
}
setLocalDescription(desc, onSucc, onErr) {
return this._auto(onSucc, onErr, () => this._setLocalDescription(desc));
}
async _setLocalDescription({ type, sdp }) {
this._checkClosed();
this._localType = type;
let action = this._actions[type];
this._sanityCheckSdp(action, type, sdp);
return this._chain(async () => {
await this._getPermission();
await new Promise((resolve, reject) => {
@ -938,21 +952,8 @@ class RTCPeerConnection {
this._remoteType = type;
let action = this._actions[type];
if (action === undefined) {
throw new this._win.DOMException(
"Invalid type " + type + " provided to setRemoteDescription",
"InvalidParameterError");
}
if (action == Ci.IPeerConnection.kActionPRAnswer) {
throw new this._win.DOMException("pranswer not yet implemented",
"NotSupportedError");
}
if (!sdp && type != "rollback") {
throw new this._win.DOMException(
"Empty or null SDP provided to setRemoteDescription",
"InvalidParameterError");
}
this._sanityCheckSdp(action, type, sdp);
// Get caller's origin before hitting the promise chain
let origin = Cu.getWebIDLCallerPrincipal().origin;