Mailing List Archive

area tag encoding dash in sku to %2d
Hi all,

I am trying to stop the area tag from encoding a dash in the sku to %2d in
mv_arg in the url, ie when using:-

<a href="[area function/stock_alert [item-code]]">[L]In-Stock
Notification[/L]</a>

If the sku is 100-10 the url generated is
/function/stock_alert?mv_arg=100%2d10

Where does the dash get encoded to %2d, I looked in Interpolate.pm and
various other files but couldn't work out where is was being encoded.

Can I make dash an allowed character somwhere?

Thanks
Re: area tag encoding dash in sku to %2d [ In reply to ]
On 10/06/17 09:10, IC wrote:
> I am trying to stop the area tag from encoding a dash in the sku to %2d
> in mv_arg in the url, ie when using:-
>
> <a href="[area function/stock_alert [item-code]]">[L]In-Stock
> Notification[/L]</a>
>
> If the sku is 100-10 the url generated is
> /function/stock_alert?mv_arg=100%2d10

It shouldn't hurt anything, but if you want it to go away try this:
[area href=function/stock_alert form="mv_arg=[item-code]"]

> Where does the dash get encoded to %2d, I looked in Interpolate.pm and
> various other files but couldn't work out where is was being encoded.
>
> Can I make dash an allowed character somwhere?

Alternatively you can replace the hexify function in Util.pm using a
globalsub (in interchange.cfg):

GlobalSub <<<EOR
sub override_hacking {
package Vend::Util;
sub hexify {
my $string = shift;
$string =~ s/([^\w-])/sprintf '%%%02x', ord($1)/ge;
return $string;
}
}
EOR


Peter

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: area tag encoding dash in sku to %2d [ In reply to ]
Quoting Peter (peter@pajamian.dhs.org):
> On 10/06/17 09:10, IC wrote:
> > I am trying to stop the area tag from encoding a dash in the sku to %2d
> > in mv_arg in the url, ie when using:-
> >
> > <a href="[area function/stock_alert [item-code]]">[L]In-Stock
> > Notification[/L]</a>
> >
> > If the sku is 100-10 the url generated is
> > /function/stock_alert?mv_arg=100%2d10
>
> It shouldn't hurt anything, but if you want it to go away try this:
> [area href=function/stock_alert form="mv_arg=[item-code]"]
>
> > Where does the dash get encoded to %2d, I looked in Interpolate.pm and
> > various other files but couldn't work out where is was being encoded.
> >
> > Can I make dash an allowed character somwhere?
>
> Alternatively you can replace the hexify function in Util.pm using a
> globalsub (in interchange.cfg):
>
> GlobalSub <<<EOR
> sub override_hacking {
> package Vend::Util;
> sub hexify {
> my $string = shift;
> $string =~ s/([^\w-])/sprintf '%%%02x', ord($1)/ge;
> return $string;
> }
> }
> EOR

I think you have one too many < in the here doc. Should work fine, though.

We could consider defining that string in Vend::Util like is done
for HTML::Entities, but the above is the functional equivalent and not
difficult to do.

--
Mike Heins
End Point -- Expert Internet Consulting http://www.endpoint.com/
phone +1.765.253.4194 <mikeh@endpoint.com>

For a successful technology, reality must take precedence over public
relations, for Nature cannot be fooled. -- Dick Feynman

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: area tag encoding dash in sku to %2d [ In reply to ]
On 10/06/17 23:32, Mike Heins wrote:
>> GlobalSub <<<EOR
>
> I think you have one too many < in the here doc. Should work fine, though.

Oops, you're right. Score one for the typo monster.

> We could consider defining that string in Vend::Util like is done
> for HTML::Entities, but the above is the functional equivalent and not
> difficult to do.

I suppose you could also do:

GlobalSub <<<EOR
sub override_hacking {
package Vend::Util;
*hexify = \&HTML::Entities::encode_entities;
}
EOR

...or something like that. In fact, is there any reason why we should
keep using hexify when we are using encode_entities everywhere else?


Peter

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: area tag encoding dash in sku to %2d [ In reply to ]
On 11/06/17 00:27, Peter wrote:
> sub override_hacking {

For the record I also meant for that to be override_hexify but it
doesn't actually matter what the sub name is there.


Peter

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: area tag encoding dash in sku to %2d [ In reply to ]
Quoting Peter (peter@pajamian.dhs.org):
> On 10/06/17 23:32, Mike Heins wrote:
> >> GlobalSub <<<EOR
> >
> > I think you have one too many < in the here doc. Should work fine, though.
>
> Oops, you're right. Score one for the typo monster.
>
> > We could consider defining that string in Vend::Util like is done
> > for HTML::Entities, but the above is the functional equivalent and not
> > difficult to do.
>
> I suppose you could also do:
>
> GlobalSub <<<EOR
> sub override_hacking {
> package Vend::Util;
> *hexify = \&HTML::Entities::encode_entities;
> }
> EOR
>
> ...or something like that. In fact, is there any reason why we should
> keep using hexify when we are using encode_entities everywhere else?

Because CGI urlencoding is not the same. It might be nice to have a pragma
or directive to route hexify, as you have done, but to change the behavior
would introduce an element of risk to applications I would not be willing
to take on.

--
Mike Heins
End Point -- Expert Internet Consulting http://www.endpoint.com/
phone +1.765.253.4194 <mikeh@endpoint.com>

Opportunity is missed by most people because it is dressed in
overalls and looks like work. -- Thomas Edison

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: area tag encoding dash in sku to %2d [ In reply to ]
On 11/06/17 00:43, Mike Heins wrote:
>> ...or something like that. In fact, is there any reason why we should
>> keep using hexify when we are using encode_entities everywhere else?
>
> Because CGI urlencoding is not the same.

Oh duh, of course it's not, it wouldn't do to have &quot; where we need %22.


Peter

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: area tag encoding dash in sku to %2d [ In reply to ]
?

On 10 June 2017 at 08:51, Peter <peter@pajamian.dhs.org> wrote:

> On 10/06/17 09:10, IC wrote:
> > I am trying to stop the area tag from encoding a dash in the sku to %2d
> > in mv_arg in the url, ie when using:-
> >
> > <a href="[area function/stock_alert [item-code]]">[L]In-Stock
> > Notification[/L]</a>
> >
> > If the sku is 100-10 the url generated is
> > /function/stock_alert?mv_arg=100%2d10
>
> It shouldn't hurt anything, but if you want it to go away try this:
> [area href=function/stock_alert form="mv_arg=[item-code]"]
>
> > Where does the dash get encoded to %2d, I looked in Interpolate.pm and
> > various other files but couldn't work out where is was being encoded.
> >
> > Can I make dash an allowed character somwhere?
>
> Alternatively you can replace the hexify function in Util.pm using a
> globalsub (in interchange.cfg):
>
> GlobalSub <<<EOR
> sub override_hacking {
> package Vend::Util;
> sub hexify {
> my $string = shift;
> $string =~ s/([^\w-])/sprintf '%%%02x', ord($1)/ge;
> return $string;
> }
> }
> EOR
>
>
> Peter
>

?Thanks for all the replies, the GlobalSub did exactly what I needed.

Andy?