Author Topic: csrf verhindert xhtml validierung / csrf prevents xhtml validation  (Read 11958 times)

0 Members and 1 Guest are viewing this topic.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Ich habe folgendes Problem:

Das CSRF verhindert bei mir die Validierung der Webseite.

In der csrf_utils.php findet man folgenden Eintrag:
function csrf_ob_handler($buffer$flags) {
    if (
preg_match('/<html/i'$buffer)) {
        
$buffer preg_replace('#(<form[^>]*method\s*=\s*["\']post["\'][^>]*>)#i''$1' csrf_form_input(), $buffer);
    }

    return 
$buffer;
}

function 
csrf_form_input() {
    global 
$csrf_protection_name$csrf_protection_xhtml;

    
$token csrf_token();
    
$endslash $csrf_protection_xhtml ' /' '';
    return 
"<input type=\"hidden\" name=\"$csrf_protection_name\" value=\"$token\"$endslash>\n";
}



Das bedeutet, dass das "Input- Feld" direkt in der "<form ..." geschrieben wird. Das ist genau mein Problem, das darf in diesem Fall nicht passieren.

In diesem Fall betrifft es nur die Suche.

Meine Suche ist so aufgebaut:
Code: [Select]
      <div id="header">
    <div id="search">
          <form method="post" action="{url_search}">
        <div class="searchContainer">
              <input type="text" tabindex="1" id="searchInput" class="inputText" name="search_keywords" value="Suchbegriffe eingeben" />
              <script type="text/javascript">
//<![CDATA[
document.getElementById('searchInput').setAttribute('autocomplete', 'off');
document.getElementById('searchInput').onfocus = function() { if (this.value == 'Suchbegriffe eingeben') this.value=''; };
document.getElementById('searchInput').onblur = function() { if (this.value == '') this.value = 'Suchbegriffe eingeben'; };
document.getElementById('searchSubmit').ondblclick = function() { window.location = 'index.php?form=Search'; };
popupMenuList.register("searchInput");
//]]>
</script>
              <div class="searchInputMenu">
In diesem Fall muss das csrf- input unter diesem <div> angebracht werden:
Code: [Select]
<div class="searchContainer">
Ich nutze XHTML 1.1
Wie kann ich das Problem beheben?
----

I have the following problem:

The CSRF prevents me from validating the website.

In csrf_utils.php find the following entry:
function csrf_ob_handler($buffer$flags) {
    if (
preg_match('/<html/i'$buffer)) {
        
$buffer preg_replace('#(<form[^>]*method\s*=\s*["\']post["\'][^>]*>)#i''$1' csrf_form_input(), $buffer);
    }

    return 
$buffer;
}

function 
csrf_form_input() {
    global 
$csrf_protection_name$csrf_protection_xhtml;

    
$token csrf_token();
    
$endslash $csrf_protection_xhtml ' /' '';
    return 
"<input type=\"hidden\" name=\"$csrf_protection_name\" value=\"$token\"$endslash>\n";
}


This means that the "input field" directly into the "<form ..." is written. That is exactly my problem, which may not happen in this case.

In this case, it only affects the search

My search is structured as follows

Code: [Select]
      <div id="header">
    <div id="search">
          <form method="post" action="{url_search}">
        <div class="searchContainer">
              <input type="text" tabindex="1" id="searchInput" class="inputText" name="search_keywords" value="Suchbegriffe eingeben" />
              <script type="text/javascript">
//<![CDATA[
document.getElementById('searchInput').setAttribute('autocomplete', 'off');
document.getElementById('searchInput').onfocus = function() { if (this.value == 'Suchbegriffe eingeben') this.value=''; };
document.getElementById('searchInput').onblur = function() { if (this.value == '') this.value = 'Suchbegriffe eingeben'; };
document.getElementById('searchSubmit').ondblclick = function() { window.location = 'index.php?form=Search'; };
popupMenuList.register("searchInput");
//]]>
</script>
              <div class="searchInputMenu">
In this case, the "csrf-input" located under this <div>:
Code: [Select]
<div class="searchContainer">
I use XHTML 1.1
How can I fix this problem?

Rembrandt

  • Guest
Re: csrf verhindert xhtml validierung / csrf prevents xhtml validation
« Reply #1 on: October 30, 2011, 05:33:41 PM »
Hi!
...
Das CSRF verhindert bei mir die Validierung der Webseite.
....Das bedeutet, dass das "Input- Feld" direkt in der "<form ..." geschrieben wird. Das ist genau mein Problem, das darf in diesem Fall nicht passieren.
...
Ich nutze XHTML 1.1
Wie kann ich das Problem beheben?
.....

das was du gepostet hast ist kein XHTML, abgesehn davon könntest du das "<div class="searchContainer">" vor "<input type=\"hidden\" name=\"$csrf_protection_name\" value=\"$token\"$endslash>\n" stellen.
aber dann mußt du bei allen Forms die gleiche Class verwenden.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: csrf verhindert xhtml validierung / csrf prevents xhtml validation
« Reply #2 on: October 30, 2011, 05:42:13 PM »
Wie kein XHTML? Wie kommst du darauf?
Meine Webseite basiert auf XHTML 1.1 und ist nur auf Grund des csrf nicht valide (Siehe Anhang)

Und ich kann "<div class="searchContainer">" nicht einfach davor setzen, dann würde es das Layout an anderen Stellen sprengen. Ich muss doch meine Seite valide bekommen auch mit dem CSRF, kann ja nicht sein das 4images da Steine in dem Weg legt

Rembrandt

  • Guest
Re: csrf verhindert xhtml validierung / csrf prevents xhtml validation
« Reply #3 on: October 30, 2011, 05:49:26 PM »
....Meine Webseite basiert auf XHTML 1.1 und ist nur auf Grund des csrf nicht valide (Siehe Anhang)

Und ich kann "<div class="searchContainer">" nicht einfach davor setzen, dann würde es das Layout an anderen Stellen sprengen. Ich muss doch meine Seite valide bekommen auch mit dem CSRF, kann ja nicht sein das 4images da Steine in dem Weg legt

du brauchst das  ""<input type=\"hidden\" name=\"$csrf_protection_name\" value=\"$token\"$endslash>\n" doch nur zwischen einen Blockelement setzen.
Da zerschiesst es dir doch gar nichts.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: csrf verhindert xhtml validierung / csrf prevents xhtml validation
« Reply #4 on: October 30, 2011, 06:24:35 PM »
Es wird doch generell automatisch nach "<form ....>" ausgegeben oder nicht?
Wie soll ich das woanders hinsetzen können?
Wenn ich "<div class="searchContainer">" vor dem hier setze "<input type=\"hidden\" name=\"$csrf_protection_name\" value=\"$token\"$endslash>\n", dann würde es durch das "class"searchContainer" an anderen Stellen das Design zerschießen!

<form ist doch auch ein Block element...
Wenn ich das so abändere:
<div><input type=\"hidden\" name=\"$csrf_protection_name\" value=\"$token\"$endslash>\n</div>
Dann ist es valide. Das verstehe ich gerade nicht so ganz



Rembrandt

  • Guest
Re: csrf verhindert xhtml validierung / csrf prevents xhtml validation
« Reply #5 on: October 30, 2011, 07:10:32 PM »
.....
<form ist doch auch ein Block element...
Wenn ich das so abändere:
<div><input type=\"hidden\" name=\"$csrf_protection_name\" value=\"$token\"$endslash>\n</div>
Dann ist es valide. Das verstehe ich gerade nicht so ganz
..
von den rede ich ja:
Quote
du brauchst das  ""<input type=\"hidden\" name=\"$csrf_protection_name\" value=\"$token\"$endslash>\n" doch nur zwischen einen Blockelement setzen.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: csrf verhindert xhtml validierung / csrf prevents xhtml validation
« Reply #6 on: October 30, 2011, 07:13:22 PM »
Aber warum muss ich das beispielsweise extra in einem DIV packen?

Rembrandt

  • Guest

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: csrf verhindert xhtml validierung / csrf prevents xhtml validation
« Reply #8 on: October 30, 2011, 07:36:02 PM »
Danke dir, mit Fieldset ist es auch besser!

Rembrandt

  • Guest
Re: csrf verhindert xhtml validierung / csrf prevents xhtml validation
« Reply #9 on: October 30, 2011, 07:46:33 PM »
ja das hatte ich seinerzeit bei meiner alten Webseite auch gemacht, bspl. aus der contactmail_form.html:
Code: [Select]
<h4>Sollten sie fragen zu eines der Bilder haben,</h4>
    <h4>können Sie hier mit mir in Kontakt treten.</h4>
    <br>
    <h4>W.A.Rumpf</h4>
<FORM style="margin:30px 0px 0px 0px;"name="inputform" action="{url_contact}" METHOD="POST">
  <fieldset>
    <legend>&nbsp;</legend>
    <label for="sender_name" class="inputform">Ihr Name:</label>
      <input style="margin:5px 5px 10px 0px"id="sender_name" name="sender_name" type="text" tabindex="1" value="{sender_name}" size="39" maxlength="50">
      <br style="clear:both">
    <label for="sender_email" class="inputform">Ihre Email:</label>
      <input style="margin:5px 5px 10px 0px"id="sender_email" name="sender_email" type="text" tabindex="2" value="{sender_email}" size="39" maxlength="50">
      <br style="clear:both">
    <label for="subject" class="inputform">{lang_subject}</label>
      <input style="margin:5px 5px 10px 0px"id="subject" name="subject" type="text"  tabindex="3" value="{subject}" size="39" maxlength="50">
      <br style="clear:both">
    <label for="message" class="inputform">{lang_message}</label>
      <textarea style="margin:5px 5px 10px 0px" id="message" name="message" cols="61" rows="10" tabindex="4">{message}</textarea>
      <br style="clear:both">
    {if captcha_contact}
      <label class="inputform">&nbsp;</label>
        <a href="javascript:new_captcha_image();"><img src="{url_captcha_image}" id="captcha_image" style="margin:5px 5px 10px 0px;border:none;" alt="captcha_image"></a>
        <br style="clear:both">
      <label for="captcha_input"class="inputform">{lang_captcha}</label>
        <input style="margin:4px 0px 0px 0px"id="captcha_input"type="text" name="captcha" size="39" tabindex="5">
        <br style="clear:both">
      <label class="inputform">&nbsp;</label>
        <div style="float:left">{lang_captcha_desc}</div>
        <br style="clear:both">
    {endif captcha_contact}
  </fieldset>
  <div style="margin-left:155px">
    <input type="hidden" name="action" value="emailSiteOwner">
    <input type="hidden" name="user_id" value="{user_id}">
    <button class= "b" tabindex="5" type="submit" name="postbutton">{lang_submit}</button>&nbsp;&nbsp;
    <button tabindex="6" type="reset" name="reset">{lang_reset}</button>
   </div>
</form>
<br>
<br>