Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images not displaying because of sanitize in FaqHelper.php #2497

Closed
lagasss opened this issue Jun 8, 2023 · 24 comments
Closed

Images not displaying because of sanitize in FaqHelper.php #2497

lagasss opened this issue Jun 8, 2023 · 24 comments
Assignees
Labels
Milestone

Comments

@lagasss
Copy link

lagasss commented Jun 8, 2023

Describe the bug
Images not displaying because of sanitize in FaqHelper.php if I comment, it works again.

Screenshots
image

phpMyFAQ (please complete the following information):

  • phpMyFAQ version : 3.1.14
  • PHP version : 7.4

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@SilentDude80
Copy link

Wow, that's the fix for my issue #2484 - thanks a lot, @lagasss !

@thorsten
Copy link
Owner

thorsten commented Jun 9, 2023

Removing this line of code opens potential security risks.

@lagasss
Copy link
Author

lagasss commented Jun 9, 2023

Removing this line of code opens potential security risks.

ok but I guess the sanitize function has to be reviewed because keeping it there breaks the display of html whenever they are images.

@thorsten
Copy link
Owner

thorsten commented Jun 9, 2023

Yes, will work on it after my holiday

@SilentDude80
Copy link

The sanitize problem is also present in 3.2.0-RC, although it behaves a little different: Images are partially displayed, but then suddenly rest of the image and rest of the articles content is cut off... commenting it out makes everything work...

@thorsten thorsten added this to the 3.1.15 milestone Jun 10, 2023
@thorsten thorsten self-assigned this Jun 10, 2023
@thorsten thorsten added the Bug label Jun 10, 2023
@thorsten
Copy link
Owner

@lagasss @SilentDude80 could you please test this fix: 0a904c1

@SilentDude80
Copy link

Cannot test in 3.1.14 at the moment, since I have it at my company and now I'm on holidays too and have no access ;-)
But I did a quick test for 3.2.0-RC which I host at home and here it throws an error, although I replaced "Sanitizer" with "HtmlSanitizer" which should be the correct variable name in 3.2.0-RC:

phpMyFAQ Fatal `error`
Uncaught exception: 'Error'

Message: 'Call to undefined method Symfony\Component\HtmlSanitizer\HtmlSanitizer::create()'

Stack trace:

#0 /var/www/html/phpmyfaq/faq.php(110): phpMyFAQ\Helper\FaqHelper->cleanUpContent()
#1 /var/www/html/phpmyfaq/index.php(793): require('...')
#2 {main}

@thorsten
Copy link
Owner

You can't use that fix for 3.2 as we switched libraries for 3.2

@thorsten
Copy link
Owner

@SilentDude80 This is the fix for 3.2: 5495a55

@SilentDude80
Copy link

@SilentDude80 This is the fix for 3.2: 5495a55

Does not work, unfortunately:

Uncaught exception: 'Error'

Message: 'Object of type Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig is not callable'

Stack trace:

#0 /var/www/html/phpmyfaq/faq.php(110): phpMyFAQ\Helper\FaqHelper->cleanUpContent()
#1 /var/www/html/phpmyfaq/index.php(793): require('...')
#2 {main}

@thorsten
Copy link
Owner

@SilentDude80 please try to revert to the original version of the file and try it again. I just added the missing options to reduce the impact of the sanitizer

@SilentDude80
Copy link

SilentDude80 commented Jun 11, 2023

@SilentDude80 please try to revert to the original version of the file and try it again. I just added the missing options to reduce the impact of the sanitizer

Ich muss jetzt mal auf Deutsch schreiben - Ich habe jetzt die ganze FaqHelper-Datei durch die von GitHub ersetzt... Mit einem kleinen Bild (das Logo von phpMyFAQ, also so Icon-Größe) hat es funktioniert. Sobald ich aber ein bissl größeres Bild verwende, kriege ich komische Fehlermeldungen:

image

Habs aber überprüft - das Bild, welches ich per Copy&Paste eingefügt habe, ist fehlerfrei im /images-Ordner gelandet.

Beim Testen ist mir auch noch aufgefallen, dass wenn ich diesen Test-Artikel bearbeite und speichere, verschwindet er mir von der Startseite, ist also weder in dem Bereich "Neue FAQs" zu sehen wie vor dem Bearbeiten, noch kann ich mich über die Kategorie durchhangeln - ist wie von der Bildfläche verschwunden. Nur über den Admin-Bereich komme ich dann noch in den Bearbeitungsmodus des Artikels... das ist aber wohl ein Fall für eine separate Fehlermeldung...

@thorsten
Copy link
Owner

@SilentDude80 Der Screenshot hat aber nichts mit dem Bug zu tun.

@thorsten
Copy link
Owner

@SilentDude80 Ich habe das nun mal mit einem sehr großen Bild (3,5 MB groß) probiert. Per Drag n Drop kommen Fehlermeldungen von TinyMCE, der Sanitizer verschluckt sich auch dran. Per Upload geht es und der Sanitizer stellt es dann auch dar. Der Commit fixt die Fehlermeldungen. Um es selbst zu testen, musst du aber den JavaScript-Code neu bauen.

@SilentDude80
Copy link

@SilentDude80 Der Screenshot hat aber nichts mit dem Bug zu tun.

Ich weiß, das liegt daran, dass ich im Moment damit kämpfe, überhaupt noch meine FAQ-Artikel angezeigt zu bekommen, um den Fix vom eigentlichen Bug testen zu können:

image

Angeblich 4 FAQs in der Kategorie - angezeigt wird aber nix...

Freigeschaltet/veröffentlicht sind sie alle:

image

Und obwohl auch drei FAQs als wichtig markiert sind, herrscht auf der Startseite in den Bereichen "Wichtige FAQs" und "Neueste FAQ-Beiträge" gähnende Leere:
image

@thorsten
Copy link
Owner

Könnte ich einen Dump deiner DB haben?

@SilentDude80
Copy link

SilentDude80 commented Jun 12, 2023

Klar:

dump.zip

Was mir noch aufgefallen ist:
Nachdem ich eine FAQ bearbeitet habe, schaltet diese in der Übersicht automatisch auf "Inaktiv". Ich setze dann zwar den entsprechenden "aktiviert"-Haken wieder, aber an der Sichtbarkeit auf der Startseite ändert das nichts...

Ist "Aktiv/Inaktiv" eigentlich dasselbe wie "Veröffentlicht/Unveröffentlicht" im Editor ?

@thorsten
Copy link
Owner

Danke für den Dump, ich schau die Tage rein.

Ist "Aktiv/Inaktiv" eigentlich dasselbe wie "Veröffentlicht/Unveröffentlicht" im Editor ?

ja, es könnte sein, dass das bereits gefixt ist. Ich denke, wir brauchen nen 2. RC

@SilentDude80
Copy link

Falls es schon gefixt ist - wäre es dann besser ich installiere noch mal den 3.2-Branch von Github ? Die Installation bei mir basiert nämlich auf "https://download.phpmyfaq.de/phpMyFAQ-3.2.0-RC.tar.gz"

@thorsten
Copy link
Owner

@SilentDude80 ja, gerne, aber dann musst du mittels Composer und Yarn die externen Bibliotheken installieren und bauen.

@SilentDude80
Copy link

Ok, null Ahnung davon - dann warte ich lieber auf RC2 ;-)

@thorsten
Copy link
Owner

@SilentDude80 Bug gefunden, ist bereits in der kommenden RC.2 gefixt.

@SilentDude80
Copy link

@SilentDude80 Bug gefunden, ist bereits in der kommenden RC.2 gefixt.

Merci :-)

@f-roscher
Copy link

@lagasss @SilentDude80 could you please test this fix: 0a904c1

@thorsten, I inserted your fixed method cleanUpContent to our running 3.1.14 and the pictures are shown again. Without that fix they had been missing.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

No branches or pull requests

4 participants