Author Topic: Bill to and Ship to not displaying ampersand symbol the same [BUG]  (Read 3377 times)

foo-wing.li

  • Beginner
  • *
  • Posts: 20
Hi,

I have noticed that if you use the ampersand symbol (&amp) within your Company Name Billing Address Information at the checkout it does not display correctly.


The ampersand displays differently on the Bill To and Ship To Cart page.
It is okay under Ship To but under the Bill To it adds an extra amp; to the html. Which caused it to display as:



Here is the HTML that is displayed
Code: [Select]
<span><span class="vmicon vm2-billto-icon"></span>
Bill To</span>
<div class="output-billto">
<!-- span class="titles">E-Mail</span -->
<span class="values vm2-email">foo-wing.li@jdwilkie.co.uk</span>
<br class="clear"/>
<!-- span class="titles">Company Name</span -->
<span class="values vm2-company">J&amp;amp;D Wilkie Ltd</span>
<br class="clear"/>
<!-- span class="titles">Title</span -->
<span class="values vm2-title">Mr</span>
<!-- span class="titles">First Name</span -->
<span class="values vm2-first_name">Foo-Wing</span>
<!-- span class="titles">Last Name</span -->
<span class="values vm2-last_name">Li</span>
<br class="clear"/>
<!-- span class="titles">Address 1</span -->
<span class="values vm2-address_1">Marwell Works</span>
<br class="clear"/>
<!-- span class="titles">Address 2</span -->
<span class="values vm2-address_2">Maywell Brae</span>
<br class="clear"/>
<!-- span class="titles">Zip / Postal Code</span -->
<span class="values vm2-zip">DD8 4BJ</span>
<!-- span class="titles">City</span -->
<span class="values vm2-city">Kirriemuir</span>
<br class="clear"/>
<!-- span class="titles">Country</span -->
<span class="values vm2-virtuemart_country_id">United Kingdom</span>
<br class="clear"/>
<!-- span class="titles">State / Province / Region</span -->
<span class="values vm2-virtuemart_state_id">Scotland</span>
<br class="clear"/>
<!-- span class="titles">Phone</span -->
<span class="values vm2-phone_1">01575 572502</span>
<br class="clear"/>
<!-- span class="titles">Mobile Phone</span -->
<span class="values vm2-phone_2">07775 707060</span>
<br class="clear"/>
<!-- span class="titles">Fax</span -->
<span class="values vm2-fax">01575 574564</span>
<br class="clear"/>
<div class="clear"></div>
</div>

Help to fix this bug would be great thanks.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9912
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #1 on: May 01, 2013, 14:25:01 pm »
very Strange, we use a "$this->escape" there. This is correct. Much more funny is, when I use Firebug and go in the line and just store it again, the ampersand is replaced by the correct &. Hmmm
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

foo-wing.li

  • Beginner
  • *
  • Posts: 20
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #2 on: May 01, 2013, 14:38:50 pm »
Thanks for looking into this for me Milbo.

@Milbo I also viewed the source code via firebug and it seems to look fine with firebug but if you view the page source via firefox Web Developer Tool Bar or Internet Explorer Page View Source Option you will see that "&amp;" is displayed as "&amp;amp;", this is very strange.

In the database it is "&amp"
But when it is called from the databse and displayed it seems to add "amp;" after the "&amp;"

franzpeter

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 467
    • 2in1-online | Software, Mac, PC, Netzwerk, Drucker, Pad, Display
  • VirtueMart Version: Virtuemart 3.2.6
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #3 on: May 01, 2013, 14:49:33 pm »
@foo-wing.li,
did you manually fill the 'Ship to' with data, or did you use 'use for the shipto same as billto?

foo-wing.li

  • Beginner
  • *
  • Posts: 20
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #4 on: May 01, 2013, 14:58:40 pm »
@franzpeter I manaully entered the data both into the ship to and bill to.
I haven't tried to use the shipto same as billto option yet.

But will do right now.

Okay I have just tried the shipto same as billto option and all it did was remove the ship to address as this is no longer needed if the shipto is the same as the billto address.


franzpeter

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 467
    • 2in1-online | Software, Mac, PC, Netzwerk, Drucker, Pad, Display
  • VirtueMart Version: Virtuemart 3.2.6
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #5 on: May 01, 2013, 15:22:39 pm »
I think it is somehow double encoded in the source code. For example if the name has a & it tries to encode that with &amp; and than encodes the & in the &amp; again. Seems that the components/com_virtuemart/views/cart/tmpl/shopper_adresses.php encodes something, what is already encoded in the database while displaying the result from the query.

foo-wing.li

  • Beginner
  • *
  • Posts: 20
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #6 on: May 01, 2013, 18:02:00 pm »
@franzpeter - I do understand what you are thinking but it should do the same for the Ship To address if that is the case. I have also looked at the shooper_address.php file and couldn't find anything wrong with that. I do need to some more investigating of my own but I thought maybe someon who coded this part of Virtuemart could maybe help.

Thanks for your time people.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9912
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #7 on: May 01, 2013, 21:41:27 pm »
Very interesting, I did this
Code: [Select]
$ret = htmlspecialchars('&', ENT_COMPAT, $this->_charset,false);
$ret1 = htmlspecialchars('&', ENT_COMPAT, $this->_charset,true);
$ret2 = htmlspecialchars('&amp;', ENT_COMPAT, $this->_charset,false);
$ret3 = htmlspecialchars('&amp;', ENT_COMPAT, $this->_charset,true);
vmdebug('htmlspecialchars & and &amp;',$ret,$ret1,$ret2,$ret3);

Result:
Code: [Select]
vmdebug htmlspecialchars & and & Var1:

&

Var2:

&

Var3:

&

Var4:

&amp;

I am just changing the last parameter, which prevents a double encoding. Here it works as expected. When I ENTER the & directly. When we get the & from the database, it seems to be different and encoded again. So just using the false is on the first view the solution. But it is not delivered as &amp; so why we need the false then?
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

franzpeter

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 467
    • 2in1-online | Software, Mac, PC, Netzwerk, Drucker, Pad, Display
  • VirtueMart Version: Virtuemart 3.2.6
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #8 on: May 01, 2013, 21:56:06 pm »
Milbo,
I do not exactly understand that. If we enter the adress, it is saved encoded to the database. So why do we need second encoding, while calling a database entry, which is encoded? The entering and saving is working (it is saving the entries encoded into the database). We just need to read out the database value without encoding. Or is that wrong?
I remember, that VM had a problem with adding something additonal with the &. But I think It was while routing and Joomla itself had already encoded.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9912
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #9 on: May 02, 2013, 00:33:48 am »
The real reason is in the model userfields kune 756, use
: @html_entity_decode($_userData[$_fld->name],ENT_COMPAT,'UTF-8'))

The problem is that we need the encoding. It works correct for anonymous users. So the problems is only, if it comes from the database, because it is stored encoded in the database.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

foo-wing.li

  • Beginner
  • *
  • Posts: 20
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #10 on: May 03, 2013, 15:00:16 pm »
I agree with franzpeter, if the & symbol(ampersand symbol) is already encoded as &amp; when it is entered into the databse why is it needed to be encoded when it is read from the database?

Isn't an anonymous user info also posted into the databse then read from the database also? Which means it is encoded going in but doesn't need to be encoded coming out?

Only data that is entered directly into the database via sql needs to be encoded when it is read from the databse just incase it wasn't entered as &amp; for the & ampersand symbol.

maxxer

  • Jr. Member
  • **
  • Posts: 76
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #11 on: June 10, 2013, 09:49:10 am »
Anyone found a fix for this?
Thanks

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9912
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #12 on: June 10, 2013, 10:31:53 am »
Try the vm2.0.21c please, it should be fixed there
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

maxxer

  • Jr. Member
  • **
  • Posts: 76
Re: Bill to and Ship to not displaying ampersand symbol the same [BUG]
« Reply #13 on: June 10, 2013, 10:59:32 am »
Try the vm2.0.21c please, it should be fixed there

thanks, but the last download I see online and in the updater it's 2.0.20b...

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9912
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/