frozeman / feindura-flat-file-cms

feindura - Flat File Content Management System
http://feindura.org
Other
38 stars 11 forks source link

GeneralFunctions::replaceSnippets() breaks content with images #16

Closed brandy007 closed 11 years ago

brandy007 commented 11 years ago

the regexp to replace the <img class="feindura..." also matches img tags without a class attribute. If my page contains

<p>
some text
<img src="image1.jpg" />
<img src="image2.jpg" />
some more text
</p>
and some more text
<p>
<img class="feindurasnippet" />
</p>
after snippet

the resulting page after replacing the snippet is

<p>
some text
<<content of snippet>>
</p>
after snippet
frozeman commented 11 years ago

hey, thank you for this bug report. when i add the reg ex from replaceSnippets()

<img(?:(?!class).)*class\=\"(feinduraSnippet|feinduraPlugin)\"(?:(?:(?!style).)*style\=\"((?:(?!").)*)")?(?:(?!title).)*title\="((?:(?!").)*)"(?:(?!>).)*>

to regexpal.com, it doesn't fit your

<img src="image1.jpg" />

because it needs at least the class feinduraSnippet or feinduraPlugin. I also can add images in my feindura installations, i didn't got this problem yet. Where did you test it?

thanks again for your effort.

brandy007 commented 11 years ago

You can see it here: http://internationale-orgelkonzerte.de/neu/seite/mediathek/test/

the source in the editor is the following:

<p>
    <span class="CUeberschrift">Die Orgel</span>
</p>

<div align="justify">
    <table cellpadding="10">
        <tbody>
            <tr>
                <td align="center" valign="middle" width="320"><a href="http://www.brandenburger.lu/ok/medien/Spieltisch1_St._Joseph_WG.JPG" rel="A" title="Impressionen vom Spieltisch*"><img alt="Impressionen vom Spieltisch*" src="http://www.brandenburger.lu/ok/medien/Spieltisch1_St._Joseph_WG_thumbnail.jpeg" style="border: 0px solid; width: 320px; height: 213px;" title="Impressionen vom Spieltisch*" /></a><br />
                Impressionen vom Spieltisch<sup>*</sup></td>
                <td align="center" valign="middle" width="320"><a href="http://www.brandenburger.lu/ok/medien/Spieltisch2_St._Joseph_WG.JPG" rel="A" title="Der Spieltisch*"><img alt="Der Spieltisch*" src="http://www.brandenburger.lu/ok/medien/Spieltisch2_St._Joseph_WG_thumbnail.jpeg" style="border: 0px solid; width: 320px; height: 213px;" title="Der Spieltisch*" /></a><br />
                Der Spieltisch<sup>*</sup></td>
            </tr>
            <tr>
                <td align="center" valign="middle" width="320"><a href="http://www.brandenburger.lu/ok/medien/Chamade_St._Joseph_002.jpg" rel="A" title="Blick von den Chamaden in das Kirchenschiff"><img alt="Blick von den Chamaden in das Kirchenschiff" src="http://www.brandenburger.lu/ok/medien/Chamade_St._Joseph_002_thumbnail.jpeg" style="border: 0px solid; width: 320px; height: 240px;" title="Blick von den Chamaden in das Kirchenschiff" /></a><br />
                Blick von den Chamaden in das Kirchenschiff</td>
                <td align="center" valign="middle" width="320"><a href="http://www.brandenburger.lu/ok/medien/Chamade_St._Joseph_004.jpg" rel="A" title="Die Beueler Chamaden"><img alt="Die Beueler Chamaden" src="http://www.brandenburger.lu/ok/medien/Chamade_St._Joseph_004_thumbnail.jpeg" style="border: 0px solid; width: 180px; height: 240px;" title="Die Beueler Chamaden" /></a><br />
                Die Beueler Chamaden</td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
        </tbody>
    </table>
    <span style="font-size: xx-small;"><sup>*</sup>Bilder Wolfgang Gourgé</span>
</div>
<!-- -->

<p>
    <img alt="loadmilkbox.php" class="feinduraSnippet" src="noImage.png" title="loadmilkbox.php" />
</p>

as Workaround I can use a class="none" attribute in the images, than it works.

I just tested it with regexpal.com - i get the result i see when i select the dot matches all box.

frozeman commented 11 years ago

thanks for your feedback, schoene orgel seite :)

but i cant really follow. where in code is something wrong? do you mean below the Bilder Wolfgang Gourgé should come an image?

also when i test the regex in regexpal.com and even if i add Dot matches all it doesn't match any image for me..

this site for example has an image inside a text and it doesnt get replaced. http://markepunktsechs.de/page/kunstler/yomayra-puentes-rivera/

but i can be thta you PHP reg ex setting are different in some way, if you can figure out whats different i can add a fix.

brandy007 commented 11 years ago

here the output of regexpal.com when it works as expected: regexp-ok

and here the output which shows the behaviour i've seen - all four images have disappeared. regexp-broken

frozeman commented 11 years ago

thanks for the pics.

add this reg ex inside the Generalfunctions::replaceSnippets() method

#<img(?:(?!>).)*class\=\"(feinduraSnippet|feinduraPlugin)\"(?:(?:(?!>).)*style\=\"((?:(?!").)*)")?(?:(?!>).)*title\="((?:(?!").)*)"(?:(?!>).)*>#i

this should fix it, i will add this to a later release.