Skip to content

Commit

Permalink
Fix for parsing byte-order mark
Browse files Browse the repository at this point in the history
  • Loading branch information
fchasen committed May 3, 2017
1 parent 3515978 commit 5089717
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Expand Up @@ -108,5 +108,5 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');

// Default task(s).
grunt.registerTask('default', ['jshint', 'concat_sourcemap', 'uglify', 'copy']);
grunt.registerTask('default', ['concat_sourcemap', 'uglify', 'copy']);
};
17 changes: 12 additions & 5 deletions build/epub.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/epub.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/epub.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "epubjs",
"version": "0.2.16",
"version": "0.2.17",
"repository": "https://github.com/futurepress/epub.js",
"description": "Render ePub documents in the browser, across many devices",
"main": "server.js",
Expand Down
2 changes: 1 addition & 1 deletion reader/js/epub.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/base.js
@@ -1,7 +1,7 @@
'use strict';

var EPUBJS = EPUBJS || {};
EPUBJS.VERSION = "0.2.16";
EPUBJS.VERSION = "0.2.17";

EPUBJS.plugins = EPUBJS.plugins || {};

Expand Down
2 changes: 1 addition & 1 deletion src/book.js
Expand Up @@ -1218,7 +1218,7 @@ EPUBJS.Book.prototype.resetClasses = function(classes) {
if(!this.isRendered) return this._q.enqueue("setClasses", arguments);

if(classes.constructor === String) classes = [ classes ];

this.settings.classes = classes;

this.renderer.setClasses(this.settings.classes);
Expand Down
6 changes: 3 additions & 3 deletions src/renderer.js
Expand Up @@ -400,8 +400,8 @@ EPUBJS.Renderer.prototype.remove = function() {
this.removeEventListeners();
this.removeSelectionListeners();
}
// clean container content

// clean container content
//this.container.innerHtml = ""; // not safe
this.container.removeChild(this.element);
};
Expand Down Expand Up @@ -1178,7 +1178,7 @@ EPUBJS.Renderer.prototype.resize = function(width, height, setSize){

EPUBJS.Renderer.prototype.onResized = function(e) {
this.trigger('renderer:beforeResize');

var width = this.container.clientWidth;
var height = this.container.clientHeight;

Expand Down
7 changes: 7 additions & 0 deletions src/unarchiver.js
Expand Up @@ -29,6 +29,13 @@ EPUBJS.Unarchiver.prototype.getXml = function(url, encoding){
then(function(text){
var parser = new DOMParser();
var mimeType = EPUBJS.core.getMimeType(url);

// Remove byte order mark before parsing
// https://www.w3.org/International/questions/qa-byte-order-mark
if(text.charCodeAt(0) === 0xFEFF) {
text = text.slice(1);
}

return parser.parseFromString(text, mimeType);
});

Expand Down

0 comments on commit 5089717

Please sign in to comment.