<commit_before>/*
* ModSecurity for Apache 2.x, http://www.modsecurity.org/
* Copyright (c) 2004-2011 Trustwave Holdings, Inc. (http://www.trustwave.com/)
*
* You may not use this file except in compliance with
* the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* If any of the files related to licensing are missing or if you have any
* other questions related to licensing please contact Trustwave Holdings, Inc.
* directly using the email address <EMAIL>.
*/

#include "modsecurity.h"
#include <ctype.h>
#include <sys/stat.h>

#include "msc_multipart.h"
#include "msc_util.h"
#include "msc_parsers.h"

void validate_quotes(modsec_rec *msr, unsigned char *data)  {
    int i, len;

    if(msr == NULL)
        return;

    if(msr->mpd == NULL)
        return;

    if(data == NULL)
        return;

    len = strlen(data);

    for(i = 0; i < len; i++)   {

        if(data[i] == '\'' && (data[0] != '\"' || data[len-1] != '\"')) {
            if (msr->txcfg->debuglog_level >= 9) {
                msr_log(msr, 9, "Multipart: Invalid quoting detected: %s length %d bytes",
                        log_escape_nq(msr->mp, data), len);
            }
            msr->mpd->flag_invalid_quoting = 1;
        }
    }
}

#if 0
static char *multipart_construct_filename(modsec_rec *msr) {
    char c, *p, *q = msr->mpd->mpp->filename;
    char *filename;

    /* find the last backward slash and consider the
     * filename to be only what's right from it
     */
    p = strrchr(q, '\\');
    if (p != NULL) q = p + 1;

    /* do the same for the forward slash */
    p = strrchr(q, '/');
    if (p != NULL) q = p + 1;

    /* allow letters, digits and dots, replace
     * everything else with underscores<commit_msg>Fix quote validation in multipart code<commit_after>/*
* ModSecurity for Apache 2.x, http://www.modsecurity.org/
* Copyright (c) 2004-2011 Trustwave Holdings, Inc. (http://www.trustwave.com/)
*
* You may not use this file except in compliance with
* the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* If any of the files related to licensing are missing or if you have any
* other questions related to licensing please contact Trustwave Holdings, Inc.
* directly using the email address <EMAIL>.
*/

#include "modsecurity.h"
#include <ctype.h>
#include <sys/stat.h>

#include "msc_multipart.h"
#include "msc_util.h"
#include "msc_parsers.h"

void validate_quotes(modsec_rec *msr, unsigned char *data)  {
    int i, len;

    if(msr == NULL)
        return;

    if(msr->mpd == NULL)
        return;

    if(data == NULL)
        return;

    len = strlen(data);

    for(i = 0; i < len; i++)   {

        if(data[i] == '\'') {
            if (msr->txcfg->debuglog_level >= 9) {
                msr_log(msr, 9, "Multipart: Invalid quoting detected: %s length %d bytes",
                        log_escape_nq(msr->mp, data), len);
            }
            msr->mpd->flag_invalid_quoting = 1;
        }
    }
}

#if 0
static char *multipart_construct_filename(modsec_rec *msr) {
    char c, *p, *q = msr->mpd->mpp->filename;
    char *filename;

    /* find the last backward slash and consider the
     * filename to be only what's right from it
     */
    p = strrchr(q, '\\');
    if (p != NULL) q = p + 1;

    /* do the same for the forward slash */
    p = strrchr(q, '/');
    if (p != NULL) q = p + 1;

    /* allow letters, digits and dots, replace
     * everything else with underscores
{'fraction_non_alphanumeric': 0.13751063226538135, 'fraction_numerical': 0.010774028919761838, 'mean_word_length': 2.475862068965517, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6778606', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1177, 'n_words': 374}