Bug 1283803 - part4 : handle unicode \u0000 and \uFFFD. draft
authorAlastor Wu <alwu@mozilla.com>
Tue, 19 Jul 2016 16:30:57 +0800
changeset 389453 a3d0814f0b4580b47991bd62610d38d2465b19eb
parent 389452 3cbf04dbd22445f0900ce1ae0941ee6bf3f19c9a
child 389454 db604e5efb3f38f37ecd5dd6f62b7674f0089c88
push id23406
push useralwu@mozilla.com
push dateTue, 19 Jul 2016 09:08:14 +0000
bugs1283803
milestone50.0a1
Bug 1283803 - part4 : handle unicode \u0000 and \uFFFD. MozReview-Commit-ID: FtDPV9U7ffS
dom/media/webvtt/vtt.jsm
testing/web-platform/meta/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/001.html.ini
--- a/dom/media/webvtt/vtt.jsm
+++ b/dom/media/webvtt/vtt.jsm
@@ -172,17 +172,17 @@ this.EXPORTED_SYMBOLS = ["WebVTT"];
     // 4.1 WebVTT timestamp
     function consumeTimeStamp() {
       var ts = collectTimeStamp(input);
       if (ts === null) {
         throw new ParsingError(ParsingError.Errors.BadTimeStamp,
                               "Malformed timestamp: " + oInput);
       }
       // Remove time stamp from input.
-      input = input.replace(/^[^\sa-zA-Z-]+/, "");
+      input = input.replace(/^[^\s\uFFFDa-zA-Z-]+/, "");
       return ts;
     }
 
     // 4.4.2 WebVTT cue settings
     function consumeCueSettings(input, cue) {
       var settings = new Settings();
 
       parseOptions(input, function (k, v) {
@@ -1261,17 +1261,18 @@ this.EXPORTED_SYMBOLS = ["WebVTT"];
         // Advance the buffer early in case we fail below.
         if (buffer[pos] === '\r') {
           ++pos;
         }
         if (buffer[pos] === '\n') {
           ++pos;
         }
         self.buffer = buffer.substr(pos);
-        return line;
+        // Spec defined replacement.
+        return line.replace(/[\u0000]/g, "\uFFFD");
       }
 
       function createCueIfNeeded() {
         if (!self.cue) {
           self.cue = new self.window.VTTCue(0, 0, "");
         }
       }
 
deleted file mode 100644
--- a/testing/web-platform/meta/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/001.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[001.html]
-  type: testharness
-  [WebVTT parser tests, nulls.vtt]
-    expected: FAIL
\ No newline at end of file