News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Bill to and Ship to not displaying ampersand symbol the same [BUG]

Started by foo-wing.li, April 30, 2013, 13:17:41 PM

Previous topic - Next topic

foo-wing.li

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

<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

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
Should I 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

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

@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

@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

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

@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

Very interesting, I did this

$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:

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?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

franzpeter

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

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.
Should I 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

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


Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

maxxer

Quote from: Milbo on June 10, 2013, 10:31:53 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

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/