• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"curl" makes form submission result in 404

#1
[eluser]Bramme[/eluser]
See my last reply please. This is very very weird.

Okay, I'm encountering one of the weirdest bugs I've ever had.

I have a form on a website I made for submitting tutorials. There's a title and short description field, an avatar image file field, a set of radiobuttons for selecting a rank and checkboxes for categories. And a larger textarea where the actual content from the tutorial comes.

When I just put "test" in that last textarea everything gets submitted fine, no problems. However when I enter a large piece of text in the textarea and hit submit, I get my 404 page. The url doesn't change and I have NO idea where the error could be thrown.

I'll try to include some relevant code.

The form:
Code:
<form action="<?php echo base_url(); ?>admin/tutorial/new_tutorial" method="post" enctype="multipart/form-data">
<div class="left">
<p>
    <label for="title">title<br />
    &lt;input type="text" name="title" id="title" value="&lt;?=$this-&gt;validation->title?&gt;" />
    </label>

</p>
<p>
    <label for="content">Description<br />
    &lt;textarea name="content" id="content" style="height: 50px"&gt;&lt;?=$this->validation->content?&gt;&lt;/textarea&gt;
    </label>
</p>
<p>
    <label for="contentHTML">contentHTML<br />
    &lt;textarea name="contentHTML" id="contentHTML" style="height: 500px"&gt;&lt;?=$this->validation->contentHTML?&gt;&lt;/textarea&gt;

    </label>
</p>
</div>
<div class="right">
<p class="lower">
    Thumbnail<br />
    If no thumbnail is selected, the cms will revert to the standard M<br />
    &lt;input type="file" name="imageLoc" id="imageLoc" /&gt;
    
</p>
<p class="lower">
    Select the rank for this tutorial: <br /><br />
    &lt;? foreach($ranks->result_array() as $rank): ?&gt;
    <label for="rank-&lt;?=$rank['rankID']?&gt;">&lt;input type="radio" name="rankID" value="&lt;?=$rank['rankID']?&gt;" id="rank-&lt;?=$rank['rankID']?&gt;" &lt;?php echo $this-&gt;validation->set_radio('rank', $rank['rankID']); ?&gt;/>&nbsp;&nbsp;&lt;?=$rank['name']?&gt;</label><br />
    &lt;? endforeach; ?&gt;
</p>
<p class="lower">
    Select the categories for this tutorial: <br /><br />
    &lt;? foreach($cats->result_array() as $cat): ?&gt;
    <label for="cat-&lt;?=$cat['catID']?&gt;">&lt;input type="checkbox" name="categories[]" value="&lt;?=$cat['catID']?&gt;" id="cat-&lt;?=$cat['catID']?&gt;" &lt;?php echo $this-&gt;validation->set_checkbox_array($cat['catID'], $this->input->post('categories')); ?&gt;/>&nbsp;&nbsp;&lt;?=$cat['name']?&gt;</label><br />
    &lt;? endforeach; ?&gt;
</p>
</div>
<p style="clear: both">
    &lt;input type="submit" name="submNewTutorial" value="Submit" /&gt;
</p>
&lt;/form&gt;

The controller:
Code:
$rules['title']     = 'trim|required|xss_clean';
        $rules['content']     = 'trim|required';
        $rules['contentHTML']     = 'required';
        $rules['rankID']     = 'required';
        $rules['categories[]'] = 'callback_required_checkbox';        
        
        $this->validation->set_rules($rules);
        
        $fields['title']     = 'tutorial title';
        $fields['content']     = 'description';
        $fields['contentHTML']     = 'actual content';
        $fields['rankID']     = 'rank radiobuttions';
        $fields['categories[]'] = 'categories';
        
        $this->validation->set_fields($fields);
        $this->validation->set_error_delimiters('<li>', '</li>');
        
        
        if ($this->validation->run() == TRUE)
        {
            if ( ! $this->backend->add_tutorial())
            {
                send_notice('error', 'Something went wrong with the query', 'self');
            }
            else
            {
                send_notice('success', 'Tutorial successfully added', 'self');
            }
        } else {
            if( ! empty($this->validation->error_string)) {
                send_notice('validation_error', $this->validation->error_string);
            }
        }

The model
Code:
function add_tutorial($edit_id = NULL) {
    // if true = no errors, if false = errors
    $error = TRUE;
    
    $insert['title'] = $this->input->post('title');
    $insert['content'] = $this->input->post('content');
    $insert['contentHTML'] = $this->input->post('contentHTML');
    $insert['rankID'] = $this->input->post('rankID');
    
    //datetime pattern example: 2006-01-03 13:24:10
    $insert['datetime'] = unix_to_human(time(), FALSE, 'eu');
    
    //code to process thumbnails
    
    // depending on wether editting or adding a tut
    if(isset($edit_id)) {
        $this->db->where('tutID', $edit_id);
        if(  ! $this->db->update('tutorial', $insert)) {
            $error = FALSE;
        }
        
    } else {
        if(  ! $this->db->insert('tutorial', $insert)) {
            $error = FALSE;
        }
    }
    
    // code that handles the categories
}

Could this have anything to do with a memory problem? Too much characters in the textarea?[/size]

#2
[eluser]manilodisan[/eluser]
Try to submit the large text without any validation and see if the error is still there. If not, we can move forward and identify this. BTW...is the XSS filter activated (global)?

#3
[eluser]Colin Williams[/eluser]
It has to do with the send_notice() function, I'm certain. Whichever one it's hitting is probably redirecting to a non-existent page.

#4
[eluser]Bramme[/eluser]
Right, I didn't think of that earlier! I'll try it at home tonight! Thanks for the hint Colin, I'll report back!

#5
[eluser]Bramme[/eluser]
Okay, after some delays, I finally got to working on the problem. Sadly, nothing worked. I commented out the send_notice thingies, deleted the validation rule for the field, changed the form action to $this->uri->uri_string(), nothing is working. When there's lots of text, I get a 404, when there's little text everything is okay.

And to answer manilodisan's question: no, the global xss filter isn't enabled. Anyone else got a clue?


edit: Okay, I'm fairly sure it's got something to do with validation, because when I enter only the long text in the area and leave all my other forms empty, I get the 404 too. Else validation always succeeds.

#6
[eluser]Bramme[/eluser]
Sorry for triple posting, but this is so weird I'd like some extra attention to help me solve this:

Editting tutorials, with similar long text works perfectly. The thing is though: editting and adding new tutorials use the same form (2 separate files though, because the edit form needs some extra comments), controller (two different functions though) and the same model function...

#7
[eluser]Bramme[/eluser]
Okay, this has gotten beyond bizarre. I noted that other long pieces of text worked, just the one I'd been trying all the time wasn't working. So I started chopping it up in pieces, to see where it went wrong. In the end, I managed to cut it down to the following word

"curl". When there's text after curl, the whole thing fails.

#8
[eluser]@li[/eluser]
Try replacing the add_tutorial() function with just one line echoing out 'done'. Then try to submit and see if it still works or not. If it still doesn't its a bug in CI, if it does its a bug in your code and we can work on resolving what it is. Let us know what happens..

#9
[eluser]Bramme[/eluser]
Still gives me the 404 error. CI bug huh, I'll report it.

#10
[eluser]@li[/eluser]
Quite weird, and it still works if you only submit one word or so like you said?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.