The form for the Credit Card Payment Method on checkout page is truncated. This form is displayed after an AJAX call to the "cart/checkout/payment_method/credit" URL.

I found out that a function that is supposed to strip out the HTML Form Tags from the Credit Card form was not working properly.

The regular expression that is supposed to remove only the Form Tags from the Credit Card form was also removing part of the Table Tags.

Comments

drupalfever’s picture

Following is an example where I put the HTML that was being generated by Ubercart in the $data variable. I, then, call the faulty "uc_strip_form()" function and do a "dsm" with the result.


$data = '<form action="/devel/php"  accept-charset="UTF-8" method="post" id="uc-payment-method-credit-form"><table class="order-edit-table"><tbody style="border-top: 0px;"><tr><td class="oet-label">Card Number:</td><td><div class="form-item" id="edit-cc-number-wrapper">
 <input type="text" maxlength="19" name="cc_number" id="edit-cc-number" size="20" value="" autocomplete="off" class="form-text" />
</div>
</td></tr><tr><td class="oet-label">Expiration Date:</td><td><div class="form-item" id="edit-cc-exp-month-wrapper">
 <select name="cc_exp_month" class="form-select" id="edit-cc-exp-month" ><option value="1" selected="selected">01 - January</option><option value="2">02 - February</option><option value="3">03 - March</option><option value="4">04 - April</option><option value="5">05 - May</option><option value="6">06 - June</option><option value="7">07 - July</option><option value="8">08 - August</option><option value="9">09 - September</option><option value="10">10 - October</option><option value="11">11 - November</option><option value="12">12 - December</option></select>
</div>
 <div class="form-item" id="edit-cc-exp-year-wrapper">
 <select name="cc_exp_year" class="form-select" id="edit-cc-exp-year" ><option value="2014" selected="selected">2014</option><option value="2015">2015</option><option value="2016">2016</option><option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option><option value="2020">2020</option><option value="2021">2021</option><option value="2022">2022</option><option value="2023">2023</option><option value="2024">2024</option><option value="2025">2025</option><option value="2026">2026</option><option value="2027">2027</option><option value="2028">2028</option><option value="2029">2029</option><option value="2030">2030</option><option value="2031">2031</option><option value="2032">2032</option><option value="2033">2033</option><option value="2034">2034</option></select>
</div>
</td></tr><tr><td class="oet-label">CVV:</td><td><div class="form-item" id="edit-cc-cvv-wrapper">
 <input type="text" maxlength="4" name="cc_cvv" id="edit-cc-cvv" size="4" value="" autocomplete="off" class="form-text" />
</div>
</td></tr></td></tr></tbody></table></form>';


dsm(uc_strip_form($data));

If you run the above exemple in a Drupal 6 website with Ubercart 2 enabled, you will find out that the Regular Expression will remove the Form Tags but it will also remove some of the Table Tags from the beginning of the example HTML code.

drupalfever’s picture

To fix the problem, I needed to alter the Regular Expression slightly.

It was originally like this:

</?form.*>

After I changed it to the following, everything worked fine:

</?form[^>]*>
drupalfever’s picture

I created this patch to fix the problem but it needs review.

drupalfever’s picture

Priority: Normal » Major
tr’s picture

Version: 6.x-2.13 » 6.x-2.x-dev
Priority: Major » Normal
Status: Patch (to be ported) » Needs review
Issue tags: -#ubercart, -error on checkout page, -ajax callback, -payment method, -credit card

Status: Needs review » Needs work

The last submitted patch, 3: ubercart-fix_removal_of_form_tag_-2332963-9121233.patch, failed testing.

drupalfever’s picture

Thanks, TR!

drupalfever’s picture

You should copy the patch to the Ubercart Module folder and execute the following command:

patch -p0 < ubercart-fix_removal_of_form_tag_-2332963-9121233.patch

I did exactly that and it works.

You need to do that on Ubercart version 6.x-2.13.

drupalfever’s picture

Version: 6.x-2.x-dev » 6.x-2.13
drupalfever’s picture

I am sorry. I chose the wrong version of Ubercart when reporting the bug. I just updated my bug report with the right version.

drupalfever’s picture

Hi, TR!
I just noticed that you changed my bug report to the wrong version. It was originally correct.

Again, the patch needs to be applied to version 6.x-2.13 in order to work.

drupalfever’s picture

Should I install the devel version of Ubercart and create the patch for that version in order for it to be tested?

I am sorry, I'm new to this...

longwave’s picture

Version: 6.x-2.13 » 6.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new480 bytes

Patches are always applied against -dev, and need to be in git format with the a/ and b/ prefixes on the filenames.

Do we need to change the end of the second regex at the same time?

tr’s picture

@drupalfever: In Drupal, patches always need to be made against the tip of the branch, which in this case is -dev. It doesn't really affect your patch, since that code has not changed in a long time so the patch won't be any different. The reason your patch didn't apply is because it was in -p0 format, rather than -p1 format as required by the testbot.

drupalfever’s picture

Thanks, guys.

It was a little stupid of me. It makes obvious sense that the patches have to be made against the Devel version of the module as opposed to a version that is already out.

TR, I will download the devel version of Ubercart and generate the new patch in the right -p1 format.

longwave, I don't think that the second Regular Expression needs to be altered.

I want to do this myself because I want to learn how to do it.

Bear with me, guys!
As I said, I am new at submitting Bug Reports...

Thanks for the help.

drupalfever’s picture

Hi, longwave! On second thought, I think you are right.

I think that we should make the same changes on the second Regula Expression as well.

I already tested the function with both Regular Expressions updated and everything seems to be working fine.

longwave’s picture

Status: Needs review » Needs work

@drupalfever: Do you want to post an updated patch with both regular expressions updated?

drupalfever’s picture

Yes longwave, I will.

I was planing to do it this weeked but things got a little hactic for me on the last few days. I will do the new patch as soon as I get home today...

Promisse!

drupalfever’s picture

Here is the new patch. Hopefully, everything is fine.

Please, check it out and test it.

longwave’s picture

Status: Needs work » Needs review
drupalfever’s picture

Is that it?

longwave’s picture

Status: Needs review » Fixed

Manually tested with your example HTML and some others I tried, works for me. Committed to 6.x-2.x, thanks for the report and patch!

  • longwave committed f1c5775 on 6.x-2.x authored by drupalfever
    Issue #2332963 by drupalfever: Fixed uc_strip_form() from removing too...
drupalfever’s picture

Thank YOU!

I feel awesome for having helped. :)

I know that Ubercart 2 is a dying version that still runs on a Drupal 6 version which is also about to be dropped in regards to support.

However, this is what I am still using at work.

My wish is that I'll be able to contribute in the future to more up to date versions of Drupal and Ubercart.

Thanks for all your help and patience longwave.

Best regards.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.