Bug 1283803 - part4 : handle unicode \u0000 and \uFFFD. r=rillian
☠☠ backed out by 242b9e254d65 ☠ ☠
authorAlastor Wu <alwu@mozilla.com>
Tue, 19 Jul 2016 11:10:56 +0800
changeset 330528 1f511a0e1484150122a25487e8ea4ce40938804d
parent 330527 2913e3ccf060235fb94ef0e811780c02d0a5393e
child 330529 2566472bdbe758d0298f57e827888b500342ca8d
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian
bugs1283803
milestone50.0a1
Bug 1283803 - part4 : handle unicode \u0000 and \uFFFD. r=rillian 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