Commit 345b010d authored by Patrick Barroca's avatar Patrick Barroca 😠
Browse files

Merge branch...

Merge branch 'hotline#105040_formulaire_articles_ne_marche_pas_avec_des_radio_boutons' into 'hotline'

hotline#105040: Formulaire : l'antispam filtrait des données valides et…

See merge request !3386
parents c93ec337 2bae308e
Pipeline #9309 passed with stage
in 58 minutes and 31 seconds
- ticket #105040 : Formulaire articles ne marche pas avec des noms d'input contenant des espaces, des tirets bas et des crochets droits
\ No newline at end of file
......@@ -56,7 +56,14 @@ class FormulaireController extends ZendAfi_Controller_Action {
$article->getContenu(),
$all_inputs);
if (array_diff(array_keys($post), $all_inputs[1]))
$clean_input = array_map(function($input)
{
return str_replace(['.',' ','['],
'_',
$input);
},
$all_inputs[1]);
if (array_diff(array_keys($post), $clean_input))
return true;
return false;
......
......@@ -31,6 +31,10 @@ abstract class FormulaireControllerPostActionTestCase extends AbstractController
'contenu' => '<form action="/formulaire/add/id_article/45" method="POST" name="Nous écrire">'
. '<p>Votre nom<input name="nom" type="text" /></p>'
. '<p>Votre prénom<input name="prenom" type="text" /></p>'
. '<p><input name="Dejeuner" required="required" type="radio" value="libre">Libre</p>'
. '<p><input name="Dejeuner" required="required" type="radio" value="Restaurant">Restaurant avec le groupe (sur réservation)</p>'
. '<p><input name="option1" type="checkbox" value="wifi">Wifi</p>'
. '<p><input name="option2" type="checkbox" value="piscine">Piscine</p>'
. '</form>']);
$this->fixture('Class_Formulaire',
['id' => 1,
......@@ -237,6 +241,107 @@ class FormulaireControllerPostAsBotTest extends FormulaireControllerPostActionTe
$this->assertRedirectTo('/');
}
/** @test */
public function withValidDataShouldCreateANewForm() {
$this->postDispatch('/formulaire/add/id_article/45',
['nom' => 'Tinguette' ,
'prenom' => 'Quentin',
'Dejeuner' => 'libre',
'option1' => 'cafe',
'option2' => 'wifi',
'website' => ''],
true);
$this->assertNotRedirectTo('/');
}
}
class FormulaireControllerPostActionDebugTestCase extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_Article::newInstanceWithId(45, ['titre' => 'Contactez nous',
'contenu' => '<form action="/arthur/formulaire/add/id_article/1618" method="POST">
<p><input name="Inscription Journée Bokeh 2 avril Talence" type="hidden" value="Inscription Journée Bokeh 2 avril Talence" />Nom, Pr&eacute;nom<br />
<input data-tc-id="w-0.29026469748912975" name="Nom, Prénom" required="required" tc-textcontent="true" type="text" /></p>
<p>Adresse mail<br />
<input data-tc-id="w-0.07789243529520828" name="Mail" required="required" tc-textcontent="true" type="email" /></p>
<p>Etablissement<br />
<input data-tc-id="w-0.0005608611335192748" name="Etablissement" required="required" tc-textcontent="true" type="text" /></p>
<p>SIGB (Nanook, Koha, PNB, Orph&eacute;e NX etc....)<br />
<input data-tc-id="w-0.8095451597979981" name="SIGB" required="required" tc-textcontent="true" type="text" /></p>
<p>Adresse de votre portail Bokeh (url en http/s)<br />
<input data-tc-id="w-0.20741370069209997" name="Site Web" tc-textcontent="true" type="url" /></p>
<p>D&eacute;jeuner</p>
<p><input data-tc-id="w-0.4082287663760651" name="Dejeuner" required="required" tc-textcontent="true" type="radio" value="libre" />Libre</p>
<p><input data-tc-id="w-0.46758368222915037" name="Dejeuner" required="required" tc-textcontent="true" type="radio" value="Restaurant" />Restaurant avec le groupe (sur r&eacute;servation)</p>
<p>&nbsp;</p>
<p><input data-tc-id="w-0.42382856730050433" tc-textcontent="true" type="submit" value="Envoyer" /></p>
<input autocomplete="off" data-spambots="true" data-tc-id="w-0.997230006041362" name="website" tc-textcontent="true" type="text" />&nbsp;</form>
<form action="/arthur/formulaire/add/id_article/1618" method="POST">
<p><input name="Inscription Journée Bokeh 2 avril Talence" type="hidden" value="Inscription Journée Bokeh 2 avril Talence" />Nom, Pr&eacute;nom<br />
<input data-tc-id="w-0.29026469748912975" name="Nom, Prénom" required="required" tc-textcontent="true" type="text" /></p>
<p>Adresse mail<br />
<input data-tc-id="w-0.07789243529520828" name="Mail" required="required" tc-textcontent="true" type="email" /></p>
<p>Etablissement<br />
<input data-tc-id="w-0.0005608611335192748" name="Etablissement" required="required" tc-textcontent="true" type="text" /></p>
<p>SIGB (Nanook, Koha, PNB, Orph&eacute;e NX etc....)<br />
<input data-tc-id="w-0.8095451597979981" name="SIGB" required="required" tc-textcontent="true" type="text" /></p>
<p>Adresse de votre portail Bokeh (url en http/s)<br />
<input data-tc-id="w-0.20741370069209997" name="Site Web" tc-textcontent="true" type="url" /></p>
<p>D&eacute;jeuner</p>
<p><input data-tc-id="w-0.4082287663760651" name="Dejeuner" required="required" tc-textcontent="true" type="radio" value="libre" />Libre</p>
<p><input data-tc-id="w-0.46758368222915037" name="Dejeuner" required="required" tc-textcontent="true" type="radio" value="Restaurant" />Restaurant avec le groupe (sur r&eacute;servation)</p>
<p>&nbsp;</p>
<p><input data-tc-id="w-0.42382856730050433" tc-textcontent="true" type="submit" value="Envoyer" /></p>
<input autocomplete="off" data-spambots="true" data-tc-id="w-0.997230006041362" name="website" tc-textcontent="true" type="text" />&nbsp;</form>
']);
$this->postDispatch('/formulaire/add/id_article/45',
[
'Inscription_Journée_Bokeh_2_avril_Talence' => 'Inscription Journée Bokeh 2 avril Talence',
'Nom,_Prénom' => 'Suzuki',
'Mail' => 'arthur.suzuki@free.fr',
'Etablissement' => 'AFI',
'SIGB' => 'koha',
'Site_Web' => 'http://sandbox.afi-sa.fr/arthur/cms/articleview/id/1618',
'Dejeuner' => 'libre',
'website' => ''
],
true);
}
/** @test */
public function responseShouldNotRedirect() {
$this->assertNotRedirectTo('/');
}
}
?>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment