Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Fehlerhafte SVG-Datei führt zu PHP Error bei Aufruf der Dateiverwaltung #8470

Closed
Mynyx opened this issue Sep 10, 2016 · 6 comments
Closed
Assignees
Labels
Milestone

Comments

@Mynyx
Copy link
Contributor

Mynyx commented Sep 10, 2016

Eine fehlerhafte SVG-Datei führt zu einem PHP Error bei Aufruf der Dateiverwaltung. Zur Reproduktion beispielsweise das letzte > in einer SVG-Datei löschen.

[10-Sep-2016 09:13:28 Europe/Berlin] 
PHP Warning: DOMDocument::loadXML(): expected '>' in Entity, line: 260 in /www/htdocs/xxx/contao/system/modules/core/library/Contao/File.php on line 261
#0 [internal function]: __error(2, 'DOMDocument::lo...', '/www/htdocs/xxx...', 261, Array)
#1 /www/htdocs/xxx/contao/system/modules/core/library/Contao/File.php(261): DOMDocument->loadXML('<svg xmlns="htt...')
#2 /www/htdocs/xxx/contao/system/modules/core/library/Contao/File.php(303): Contao\File->__get('imageSize')
#3 /www/htdocs/xxx/contao/system/modules/core/library/Contao/File.php(351): Contao\File->__get('imageViewSize')
#4 /www/htdocs/xxx/contao/system/modules/core/drivers/DC_Folder.php(2453): Contao\File->__get('viewHeight')
#5 /www/htdocs/xxx/contao/system/modules/core/drivers/DC_Folder.php(308): Contao\DC_Folder->generateTree('/www/htdocs/xxx...', 0, false, false, false)
#6 /www/htdocs/xxx/contao/system/modules/core/classes/Backend.php(650): Contao\DC_Folder->showAll()
#7 /www/htdocs/xxx/contao/system/modules/core/controllers/BackendMain.php(131): Contao\Backend->getBackendModule('files')
#8 /www/htdocs/xxx/contao/contao/main.php(20): Contao\BackendMain->run()
#9 {main}

[10-Sep-2016 09:13:28 Europe/Berlin] PHP Fatal error:  Call to a member function getAttribute() on null in /www/htdocs/xxx/contao/system/modules/core/library/Contao/File.php on line 266
@leofeyer
Copy link
Member

Ja klar, die Datei ist ja auch fehlerhaft. Was sollte Deiner Meinung nach passieren?

@Mynyx
Copy link
Contributor Author

Mynyx commented Sep 10, 2016

Ein Zugriff auf die Dateiverwaltung ist wegen des Fatal Error nicht mehr möglich. (Also nicht nur das Bearbeiten der spezifischen Datei sondern die gesamte Dateiverwaltung!)

Es sollte zuerst die Datei auf Validität geprüft werden bevor Operationen durchgeführt werden, die zu einem PHP Error führen. Man könnte auch nach Alternativen für die verwendeten Funktionen sehen, die eine Fehlerhandling mit Exceptions haben, damit man diese abfangen könnte.

@fritzmg
Copy link
Contributor

fritzmg commented Sep 10, 2016

Errorneous JPGs cause fatal errors as well currently, don't they?

@discordier
Copy link
Contributor

The fatal is a follow up error. We have to check if the resource is null before using it.

@Mynyx
Copy link
Contributor Author

Mynyx commented Sep 11, 2016

Der Rückgabewert der Funktion gibt auch Auskunft darüber, ob Fehler aufgetreten sind, sodass eine Lösung wie folgt aussehen könnte: if (@$doc->loadXML(...

http://php.net/manual/en/domdocument.loadxml.php#refsect1-domdocument.loadxml-returnvalues

@leofeyer leofeyer added this to the 3.5.17 milestone Sep 12, 2016
@leofeyer leofeyer self-assigned this Sep 19, 2016
@leofeyer
Copy link
Member

Geändert in d59ea0e.

jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Sep 24, 2016
### 4.2.4 (2016-09-21)

 * Handle special character passwords in the "close account" module (see contao/core#8455).
 * Handle broken SVG files in the Image and File class (see contao/core#8470).
 * Reduce the maximum field length by the file extension length (see contao/core#8472).
 * Fall back to the field name if there is no label (see contao/core#8461).
 * Do not assume NULL by default for binary fields (see contao/core#8477).
 * Correctly render the diff view if not the latest version is active (see contao/core#8481).
 * Update the list of countries and languages (see contao/core#8453).
 * Correctly set up the MooTools CDN URL (see contao/core#8458).
 * Also check the URL length when determining the search URL (see contao/core#8460).
 * Only regenerate the session ID upon login.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants