summaryrefslogtreecommitdiff
path: root/src/svg/qsvgtinydocument.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Avoid undefined behavior when painter transform goes oobEskil Abrahamsen Blomfeldt2022-07-141-0/+11
| | | | | | | | | | | | | | With some broken input files, we can end up with a matrix that scales or translates so far that it ends up with NaNs or Infs. This causes undefined behavior later when doing comparisons. We protect against this by checking for matrix validity after transforming and resetting the matrix if it becomes invalid. Pick-to: 5.15 6.2 6.3 6.4 Fixes: QTBUG-101698 Change-Id: Iabc745c1e7a0c36449f14c4c6d9bc8066eaa8eac Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-131-38/+2
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: Ie5a75414af5fda27f5b5f527f3543b088b674677 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Remove outdated version checksRobert Löhning2022-03-151-4/+0
| | | | | Change-Id: Ida0c5d3ed25322c736617934aef9f3a8e4daf4c3 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Replace 0 with nullptrZhang Hao2021-10-151-2/+2
| | | | | | | | We know that c++11 uses nullptr to replace 0, so we replace 0 with nullptr in the project. Change-Id: I81eb8c13339bf235ca5eab719526680e31fa26ed Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
* Allow loading SVG files with a doctype declarationNicolas Fella2020-10-211-2/+2
| | | | | | | | | | | | | | | SVGs may have a DOCTYPE declaration (https://www.w3.org/TR/2003/REC-SVGMobile-20030114/) in their first line. This patch makes sure those SVGs are loaded properly Fixes: QTBUG-87583 Pick-to: 5.15 5.12 Change-Id: Ia3dcb519b6ee2b498dc81ef496764d99ea6c4a9a Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Avoid recursion when inflating compressed svgsEirik Aavitsland2020-08-281-10/+14
| | | | | | | | | | | Avoid the possibility of recursion loop for corrupt compressed files, and generally simplify the code, particularly the handling of the QT_NO_COMPRESS flag. Pick-to: 5.15 5.12 Change-Id: Ic21a4814a45c4303cc366152be65ae54fa973461 Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Implement basic format check also for compressed svgsEirik Aavitsland2020-08-271-6/+19
| | | | | | | | | | | | | | | | For uncompressed files, QSvgIOhandler::canRead() will reject any file that does not start out with a svg or xml tag. That rudimentary check was never done for compressed files (svgz). Implement the check during the decompressing itself, so that we can fail early and not waste time and memory decompressing potentially huge files that are anyway not valid svgs. Fixes: oss-fuzz-24611 Pick-to: 5.15 5.12 Change-Id: I154efd8adafe7f09307e8b28a66b536539b1e4bd Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Don't return partially inflated QByteArrayRobert Loehning2020-08-261-1/+1
| | | | | | | | | | We're already stopping the extraction because we're running out of memory. It's no use to return this provisional result. Pick-to: 5.12 5.15 Task-number: oss-fuzz-24611 Change-Id: Iea5a65a0f30b7a03c5405017c21cd9495a7c2971 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Initialize QSvgHandler with QBuffer instead of QByteArrayRobert Loehning2020-08-241-1/+4
| | | | | | | | | Reduces memory consumption significantly for huge files. Fixes: oss-fuzz-24347 Pick-to: 5.15 Change-Id: Iebf58d5f73030336d219ad770e1d1d2798c10067 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use qFuzzyIsNull instead of isEmpty() on QRectFRobert Loehning2020-07-301-1/+1
| | | | | | | | | | Avoids an integer overflow in QOutlineMapper Fixes: oss-fuzz-24131 Pick-to: 5.12 5.15 Change-Id: I77a280640df4971e440d3f8888d2e7036a1f2e6a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Avoid endless recursion when inflating gzipRobert Loehning2020-07-291-3/+5
| | | | | | | Fixes: oss-fuzz-24146 Pick-to: 5.12 5.15 Change-Id: I52a974e6a0694fb4afb50d932b2e99917c3034b2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Return nullptr instead of 0Robert Loehning2020-07-241-1/+1
| | | | | | Pick-to: 5.12 5.15 Change-Id: I200214f90ce399034dabc61b00d20f7def8d923d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix oom in QSvgTinyDocument::loadAllan Sandfeld Jensen2020-06-231-0/+6
| | | | | | | | | | | Avoid overflowing the size integer. Fixes ozz-fuzz 23606 Pick-to: 5.15 5.12 Change-Id: Iaae2c1e78e59737bba0e34791de4a3a92677f319 Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use QRect::isEmpty instead of QRect::isNullAllan Sandfeld Jensen2020-06-221-5/+5
| | | | | | | | | | | Otherwise we can end up processing empty rects, and get divisions by zero. Fixes oss-fuzz issue 23633. Pick-to: 5.15 5.12 Change-Id: I0415462712792cb6a00eadd510b1688e859c419c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add API to enable opt-in aspect ratio feature in QSvgRendererEirik Aavitsland2020-01-281-0/+5
| | | | | | | | | [ChangeLog][QSvgRenderer] Introduced aspect ratio mode property, so that rendering may be set to preserve the view box aspect ratio. Task-number: QTBUG-81259 Change-Id: I9802788cdaf2c30974c1ffc34ad5b67cdc74ed57 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-01-281-7/+8
|\ | | | | | | Change-Id: I987599c388f414928aabf6a193a8250c27f4f60d
| * Revert the keep-aspectratio feature for 5.14.1v5.14.15.14.1Eirik Aavitsland2020-01-161-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was introduced as non-optional behavior for 5.14.0, but caused many regressions. This patch reverts that, and instead prepares for introducing it as an opt-in feature in Qt 5.15. [ChangeLog][QSVGRenderer] In Qt 5.14.0, rendering would keep aspect ratio implied by the viewbox, independently of the specified target area. This caused many regressions with existing code, so is reverted now in 5.14.1. The feature will instead be available as an opt-in in Qt 5.15. Task-number: QTBUG-81259 Change-Id: I3efa2db864eb80ee00e8a067e56d9912bab36442 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | Don't use deprecated QMatrix class anymoreJarek Kobus2020-01-171-3/+4
|/ | | | | | Task-number: QTBUG-46653 Change-Id: I9944b62141d7054e3935000a819bebc5fd54df6c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix yet another viewbox scaling issue, for render to boundsEirik Aavitsland2020-01-031-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | The recent introduction of keepAspectRation scaling led to wrong output (outside bounds) in the case of an explicitly specified target bounds rect, i.e. QSVGRenderer::render(QPainter *p, QRectF bounds). Fix by reverting to old code path in this case, i.e. allow the user to override the keepAspectRatio behavior by explicitly specifying target bounds. As a driveby, also fix the keepAspectRatio code path in case of a target rect having non-zero x/y coordinates. Now the fix above means that this will never happen in the code as it stands, but it may come in handy later. [ChangeLog][QSVGRenderer] From Qt 5.14.0, normal rendering will keep aspect ratio implied by the viewbox. The render() methods taking an explicit target bounds QRectF parameter can now be used to override that behavior. They will scale the output to the bounds while ignoring aspect ratio, as was the default rendering prior to 5.14.0. Fixes: QTBUG-80888 Change-Id: I399b05ca50d290b8e4b01bdc47b5b6f74c890c9a Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Re-fix scaling when rendering a specific element by idAlessandro Portale2019-11-141-1/+3
| | | | | | | | | | | | | | | | | | | | | This is a modification of 14fa4591eb34a35cf3d485fd901e3f1e2caa7770 That patch corrected the handling of the view box when rendering an entire SVG document. However, contrary to intention stated in the comment of that patch, it turns out that the new viewbox handling code path can be taken also for the case of rendering only a single element by id. Instead, we want to keep the original behavior where the element's origin bounds are transformed to fit into the user requested target bounds, allowing non-proportional scaling. Since the render-single-element case is easily and uniqely identifiable by the sourceRect parameter being non-null, just add an explicit check for that to the code path branching. Done-with: Eirik Aavitsland <eirik.aavitsland@qt.io> Fixes: QTBUG-79933 Change-Id: I64a35bbb193db22c33670b48ea165a91df8e719e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QSvgRenderer: Allow to remove a viewBoxAlessandro Portale2019-11-131-1/+1
| | | | | | | | | | m_implicitViewBox needs to be true if the explicit viewBox is null. That relationship between m_viewBox and m_implicitViewBox can be see in QSvgTinyDocument::viewBox(). Task-number: QTBUG-79933 Change-Id: I6ea5a849479b10117128bcaf1799e3770b145e77 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix rendering of SVG with translating viewBoxEirik Aavitsland2019-11-111-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | This is a modification of14fa4591eb34a35cf3d485fd901e3f1e2caa7770. That change correctly implemented support for scaling and centering viewBox. However, the viewBox scaling and x-min/y-min translation was applied in the wrong order, so SVGs with a non-zero x-min/y-min viewBox would be rendered with an offset. The autotest reflected this error, and is also fixed here. (In user space, the black rectangle's upper left corner (0,0) is in the center of the viewBox and so should end up in the center of the produced image, independently of the scaling. All other tested SVG renderers place it there.) This change fixes all the reported regression cases from the above commit, while not re-breaking the original cases fixed by that commit. Fixes: QTBUG-79333 Fixes: QTBUG-78200 Task-number: QTBUG-70256 Change-Id: I0d3394e3caf6ec7edf16a10992c2fbfdac7398e5 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Convert uses of QTime as a timer to QElapsedTimerEdward Welbourne2019-06-131-10/+9
| | | | | | | | | | | | One was an easy replacement, the other changes its reference time, which isn't supported by QElapsedTimer. However, it was easy enough to reimplement in terms of QDateTime::currentMSecsSinceEpoch(); and, as it was previously using QTime as timer, this is presumably good enough (although a proper monotonic timer would be better). Change-Id: I90f8e08635e7d2bc364755efd93fce008b6a62c0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Fix rendering of SVGs with viewBoxesSimon Hausmann2019-05-241-8/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | The presence of the viewBox attribute in the svg tag implies the presence of the preserveAspectRatio attribute as well. It defaults to scaling the view box to the view port while preserving the aspect ratio and the box is also centered. This patch does not implement the full preserveAspectRatio attribute, but it does implement the default of aspect ratio preservation and centering, as that is what caused the rendering error in the linked task. This causes some tests in the SVG Tiny 1.2 test suite to differ. This is visible using the rendertestsuite helper program (see other change). In particular it corrects the rendering of struct-svg-203-t.svg to correctly center the text and avoid scaling it. For animate-elem-38-t.svg the rendering improved by making the entire text visible, as in the reference. The same applies to media-video-216-t.svg. In both rendering the scaling changes slightly. Done-With: Rainer Keller <rainer.keller@qt.io> Fixes: QTBUG-70256 Change-Id: I9142c511890765993ee3e316f0383550919fdcd4 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix IRI parsing, and use after freeAllan Sandfeld Jensen2019-03-041-1/+4
| | | | | | | | | | Make the parsing of IRI references tighter, and avoid freeing styles when inserting a duplicate id. Fixes: QTBUG-74104 Change-Id: I3a12fcf09ce1c55c135a4209817413ed8af75dec Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Don't leak nodes on parsing failuresAllan Sandfeld Jensen2019-02-271-1/+6
| | | | | | | | | | | The QSvgHandler always expects the caller to handle ownership of the generated document, also when the parsing failed. QSvgHandler also failed to handle misplaced group elements. Fixes: QTBUG-74083 Change-Id: I8907117d4305ecd84e328b201791001cb877fc60 Reviewed-by: Robert Loehning <robert.loehning@qt.io>
* Introduce logging category "qt.svg"Friedemann Kleint2017-02-021-7/+7
| | | | | | | | | | | It is then possible to suppress warnings by setting for example QT_LOGGING_RULES to qt.svg.warning=false. This will suppress the warnings floods which are currently produced by faulty theme svg icons on KDE 5 systems. Task-number: QTBUG-52079 Change-Id: I50e3c2e3eab610e182293c8938c6188694eabfb7 Reviewed-by: David Faure <david.faure@kdab.com>
* Updated license headersJani Heikkinen2016-01-251-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I4bbd8b2a35222b925c6e5cef6337e6237d3e1716 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: Ie7d37928ebd680c6f1b20045de11abcd5595c73f Reviewed-by: Jani Heikkinen <jani.heikkinen@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Correctly handle Miter joins in all casesLars Knoll2014-10-201-2/+2
| | | | | | | | SVG uses SvgMiterJoin, not the Qt definition of miter joins at all times. Change-Id: I85b8e13609fa37384f09457f724a42d720769028 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
* Update license headers and add new license filesv5.4.0-alpha1Antti Kokko2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I847adeea20fd98e5c9a18b8c44a15de84283f216 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* remove pointless #ifndef QT_NO_SVGOswald Buddenhagen2013-10-291-4/+0
| | | | | | | the way to disable the feature is to not compile the module. Change-Id: I96f18d037243f7d6e3b3cb2c23922cc4c05c30a8 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
* Fix module name format in file headersSze Howe Koh2013-01-291-1/+1
| | | | | | | | | Follow the conventions at http://qt-project.org/wiki/Spelling_Module_Names_in_Qt_Documentation Change-Id: I418bbd3817d433a1b82f0f0fea68f2235d2abc5a Reviewed-by: Jerome Pasion <jerome.pasion@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-101-1/+1
| | | | | | Change-Id: Icf9d15a0f1f38ab60f0dd8fc2bc6ac936dd7dc62 Reviewed-by: Akseli Salovaara <akseli.salovaara@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-241-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: Ie28eae89f2ad032f174ff840cc6a44d8dd511eed Reviewed-by: Janne Anttila <janne.anttila@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I5f2eda9477944e22ec5f6dd07dcb53feaa9fc03b Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update obsolete contact address.Jason McDonald2012-01-231-1/+1
| | | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: Ia89ccb618e630103d60a6e2703e3fbedae0616a6 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | | Change-Id: I2dda86020c6d4b3edf8461733b14a95b9e519afc Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update licenseheader text in source files for qtsvg Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+492
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12