Merge pull request #14558 from Snuffleupagus/getFilenameFromContentDispositionHeader-TextDecoder
Remove the UTF-8 fallback, when `TextDecoder` is missing, from the Content-Disposition parser
This commit is contained in:
		
						commit
						7ee531d918
					
				@ -19,7 +19,6 @@ import { stringToBytes } from "../shared/util.js";
 | 
				
			|||||||
// https://github.com/Rob--W/open-in-browser/blob/7e2e35a38b8b4e981b11da7b2f01df0149049e92/extension/content-disposition.js
 | 
					// https://github.com/Rob--W/open-in-browser/blob/7e2e35a38b8b4e981b11da7b2f01df0149049e92/extension/content-disposition.js
 | 
				
			||||||
// with the following changes:
 | 
					// with the following changes:
 | 
				
			||||||
// - Modified to conform to PDF.js's coding style.
 | 
					// - Modified to conform to PDF.js's coding style.
 | 
				
			||||||
// - Support UTF-8 decoding when TextDecoder is unsupported.
 | 
					 | 
				
			||||||
// - Move return to the end of the function to prevent Babel from dropping the
 | 
					// - Move return to the end of the function to prevent Babel from dropping the
 | 
				
			||||||
//   function declarations.
 | 
					//   function declarations.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -92,14 +91,6 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
 | 
				
			|||||||
        needsEncodingFixup = false;
 | 
					        needsEncodingFixup = false;
 | 
				
			||||||
      } catch (e) {
 | 
					      } catch (e) {
 | 
				
			||||||
        // TextDecoder constructor threw - unrecognized encoding.
 | 
					        // TextDecoder constructor threw - unrecognized encoding.
 | 
				
			||||||
        // Or TextDecoder API is not available (in IE / Edge).
 | 
					 | 
				
			||||||
        if (/^utf-?8$/i.test(encoding)) {
 | 
					 | 
				
			||||||
          // UTF-8 is commonly used, try to support it in another way:
 | 
					 | 
				
			||||||
          try {
 | 
					 | 
				
			||||||
            value = decodeURIComponent(escape(value));
 | 
					 | 
				
			||||||
            needsEncodingFixup = false;
 | 
					 | 
				
			||||||
          } catch (err) {}
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return value;
 | 
					    return value;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user