Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added version check before stripping of invalid Characters for Edge/… #775

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/FileSaver.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ var _global = typeof window === 'object' && window.window === window
? global
: this

function stripNameOfInvalidChars(name) {
var isEdge17_17134 = /Edge\/17.17134/.test(navigator.userAgent)
if(isEdge17_17134){
var forbiddenChars = ['<', '>', ':', '"', '/', '\\', '|', '?', '*'];
for(var i = 0;i < forbiddenChars.length; i++) {
name = name.replace(forbiddenChars[i], '_');
}
}
return name;
}

function bom (blob, opts) {
if (typeof opts === 'undefined') opts = { autoBom: false }
else if (typeof opts !== 'object') {
Expand Down Expand Up @@ -83,6 +94,7 @@ var saveAs = _global.saveAs || (
// Namespace is used to prevent conflict w/ Chrome Poper Blocker extension (Issue #561)
var a = document.createElementNS('http://www.w3.org/1999/xhtml', 'a')
name = name || blob.name || 'download'
name = stripNameOfInvalidChars(name);

a.download = name
a.rel = 'noopener' // tabnabbing
Expand Down