exifreader 4.52.0 → 4.53.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.
- package/README.md +36 -15
- package/dist/exif-reader.js +1 -1
- package/dist/exif-reader.js.map +1 -1
- package/package.json +4 -4
- package/src/dom-parser.js +54 -4
- package/src/exif-reader.js +1 -2
- package/src/load-auto.js +11 -0
- package/src/node-require.js +8 -1
- package/src/tag-names-0th-ifd.js +5 -1
- package/src/tag-names-utils.js +27 -2
- package/src/tags-helpers.js +15 -7
- package/src/types.js +32 -2
- package/src/xmp-element-depth.js +16 -26
- package/src/xmp-tags.js +3 -3
package/README.md
CHANGED
|
@@ -709,10 +709,15 @@ parser needs to have a `parseFromString` method with the same API as the
|
|
|
709
709
|
[`parseFromString` from the DOMParser Web
|
|
710
710
|
API](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString).
|
|
711
711
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
712
|
+
Use [`xmldom`](https://www.npmjs.com/package/@xmldom/xmldom) 0.9.12 or later.
|
|
713
|
+
ExifReader limits how deeply XMP elements can nest and how many markup nodes a
|
|
714
|
+
packet can have, and it checks those limits the way `xmldom` reads markup.
|
|
715
|
+
|
|
716
|
+
[`linkedom`](https://www.npmjs.com/package/linkedom) also parses XMP correctly,
|
|
717
|
+
but use it only for files you trust. ExifReader's limits do not hold with it: a
|
|
718
|
+
crafted 1 MB file can block parsing for about a minute, and a larger one for
|
|
719
|
+
longer. `linkedom` can also get stuck on some XML (see below). Other parsers
|
|
720
|
+
may work if they follow the spec, with the same caveat.
|
|
716
721
|
|
|
717
722
|
Here is an example using `xmldom`:
|
|
718
723
|
|
|
@@ -722,11 +727,6 @@ import {DOMParser, onErrorStopParsing} from '@xmldom/xmldom';
|
|
|
722
727
|
const tags = ExifReader.load(fileBuffer, {domParser: new DOMParser({onError: onErrorStopParsing})});
|
|
723
728
|
```
|
|
724
729
|
|
|
725
|
-
Use `xmldom` 0.9.12 or later. ExifReader limits how deeply XMP elements can
|
|
726
|
-
nest and how many markup nodes a packet can have, and it checks those limits
|
|
727
|
-
the way `xmldom` 0.9 reads the markup. With 0.8, a crafted file can get past
|
|
728
|
-
them and make parsing slow.
|
|
729
|
-
|
|
730
730
|
The `onError` option is needed to avoid a [seemingly infinite loop for some
|
|
731
731
|
XMLs](https://github.com/xmldom/xmldom/issues/501). Unfortunately `linkedom` has
|
|
732
732
|
the same problem but does not have this option and will therefore get stuck on
|
|
@@ -734,6 +734,22 @@ these XMLs. If this happens to you, switch to `xmldom` and pass in the `onError`
|
|
|
734
734
|
option. (NOTE: The native `DOMParser` that a web browser uses does not seem to
|
|
735
735
|
have this issue.)
|
|
736
736
|
|
|
737
|
+
Versions of `xmldom` older than 0.9.12 read some markup differently,
|
|
738
|
+
well-formed markup included, so with them a crafted file can get past the
|
|
739
|
+
limits and make parsing slow. ExifReader also skips an XMP packet that has a
|
|
740
|
+
DOCTYPE or another markup declaration, since a parser such as a browser's
|
|
741
|
+
native `DOMParser` can expand the entities declared in a DOCTYPE into markup
|
|
742
|
+
the limits do not see.
|
|
743
|
+
|
|
744
|
+
If you pass no `domParser` and there is no global `DOMParser`, ExifReader tries
|
|
745
|
+
to load `@xmldom/xmldom` itself. It then skips XMP, with a warning, if the copy
|
|
746
|
+
it finds is older than 0.9.12 or its version cannot be read. That copy can be
|
|
747
|
+
the one at the top of your `node_modules` instead of ExifReader's own, for
|
|
748
|
+
example when ExifReader is installed without optional dependencies, or when an
|
|
749
|
+
npm override, a Yarn resolution or a pnpm override pins `@xmldom/xmldom` below
|
|
750
|
+
0.9.12. Install `@xmldom/xmldom` 0.9.12 or later, or pass a parser in the
|
|
751
|
+
`domParser` option.
|
|
752
|
+
|
|
737
753
|
#### Using React Native
|
|
738
754
|
|
|
739
755
|
Import ExifReader like this:
|
|
@@ -966,12 +982,17 @@ given, so pass them the same one as the build: a project that builds with
|
|
|
966
982
|
configuration is found and `--check` exits with 0.
|
|
967
983
|
|
|
968
984
|
**Deprecated: automatic rebuild on install.** Older versions rebuilt the library
|
|
969
|
-
automatically through an npm `postinstall` script, so a plain install or
|
|
970
|
-
rebuild exifreader` (or `yarn
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
985
|
+
automatically through an npm `postinstall` script, so a plain install or
|
|
986
|
+
`npm rebuild exifreader` (or `yarn add exifreader` with yarn 1) produced the
|
|
987
|
+
custom bundle. This still works in v4 but is deprecated and will be removed in
|
|
988
|
+
v5, because npm is phasing out automatic install scripts. Yarn 4.14 and later
|
|
989
|
+
disable dependency build scripts by default (an install prints
|
|
990
|
+
`YN0004 ... all build scripts have been disabled`), so there the install-time
|
|
991
|
+
build only runs if you enable build scripts, with Yarn's `enableScripts` setting
|
|
992
|
+
or the `built` flag in `dependenciesMeta`. Use `npx exifreader build` (or
|
|
993
|
+
`yarn exifreader build` with Yarn) instead, which does not depend on build
|
|
994
|
+
scripts. With Yarn 2+ it needs a `node_modules` install
|
|
995
|
+
(`nodeLinker: node-modules` in `.yarnrc.yml`), not Plug'n'Play.
|
|
975
996
|
|
|
976
997
|
If you are using `vite`, you will need to [clear the dependency cache](https://vitejs.dev/guide/dep-pre-bundling.html#file-system-cache)
|
|
977
998
|
after a rebuild.
|