exifreader 4.46.0 → 4.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,24 +2,39 @@
2
2
  * License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
4
 
5
+ const CHROME_MESSAGE_START = 'Namespace prefix ';
6
+ const CHROME_MESSAGE_END = ' is not defined';
7
+
5
8
  export function isMissingNamespaceError(error) {
9
+ const message = String(error.message);
6
10
  const missingNamespaceStrings = [
7
11
  // @xmldom/xmldom
8
12
  'prefix is non-null and namespace is null',
9
13
  // Firefox
10
14
  'prefix not bound to a namespace', // en
11
- 'prefix inte bundet till en namnrymd', // sv
12
- // Chrome
13
- /Namespace prefix .+ is not defined/
15
+ 'prefix inte bundet till en namnrymd' // sv
14
16
  ];
15
17
 
16
18
  for (let i = 0; i < missingNamespaceStrings.length; i++) {
17
- const regexp = new RegExp(missingNamespaceStrings[i]);
18
- if (regexp.test(error.message)) {
19
+ if (message.indexOf(missingNamespaceStrings[i]) !== -1) {
19
20
  return true;
20
21
  }
21
22
  }
22
23
 
24
+ return isChromeMissingNamespaceMessage(message);
25
+ }
26
+
27
+ // Same result as the former Chrome check /Namespace prefix .+ is not defined/,
28
+ // in linear time.
29
+ function isChromeMissingNamespaceMessage(message) {
30
+ const lines = message.split(/[\n\r\u2028\u2029]/);
31
+ for (let i = 0; i < lines.length; i++) {
32
+ const prefixIndex = lines[i].indexOf(CHROME_MESSAGE_START);
33
+ if (prefixIndex !== -1
34
+ && lines[i].lastIndexOf(CHROME_MESSAGE_END) > prefixIndex + CHROME_MESSAGE_START.length) {
35
+ return true;
36
+ }
37
+ }
23
38
  return false;
24
39
  }
25
40
 
@@ -93,11 +108,11 @@ function scanStartTag(xmlString, fromIndex) {
93
108
  return {insertionIndex: -1, attributeValueSpans};
94
109
  }
95
110
 
96
- function hasSubstringAt(xmlString, substring, index) {
111
+ export function hasSubstringAt(xmlString, substring, index) {
97
112
  return xmlString.slice(index, index + substring.length) === substring;
98
113
  }
99
114
 
100
- function skipPast(xmlString, fromIndex, endMarker) {
115
+ export function skipPast(xmlString, fromIndex, endMarker) {
101
116
  const endIndex = xmlString.indexOf(endMarker, fromIndex);
102
117
  if (endIndex === -1) {
103
118
  return xmlString.length;