Bug #67887 [NEW]: the URL rewrite mechanism handles `<a href=\"javascript` in a surprising manner

From: Date: Fri, 22 Aug 2014 14:32:49 +0000
Subject: Bug #67887 [NEW]: the URL rewrite mechanism handles `<a href=\"javascript` in a surprising manner
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187239@lists.php.net to get a copy of this message
From:             ndermine at adequasys dot com
Operating system: windows, mac os x, debian
PHP version:      5.5.16
Package:          Output Control
Bug Type:         Bug
Bug description:the URL rewrite mechanism handles <a href=\"javascript in a
surprising manner

Description:
------------
I use output_add_rewrite_var to add a URL parameter to relative links in
my app.

When I have a link like this <a href="javascript:..."> it is left
untouched which is great.

But I had a piece of javascript containing an anchor tag inside a
javascript string :
"<a href=\"javascript..." (note the escaped double quote that is
expected to remain escaped in the HTML page source)

That part was modified in a way that broke the javascript : the new
param was introduced between the backslash and the double quote :

"<a href=\?key=value"javascript..."

I can of course write (and have rewritten) my javascript differently,
but would it be possible to not insert the parameters in this case?

This seems very similar to Bug #19358 "URL Rewriter Blindly Replaces All
Links" (closed because of lack of feedback) which was submitted in
2002.

Thank you for your work.

Test script:
---------------
<?php
output_add_rewrite_var('a', 'b');
?>
<script type="text/javascript">
var link = "<a href=\"javascript:doSomething('with a
parameter')\">link</a>";
</script>


Expected result:
----------------
<script type="text/javascript">
var link = "<a href=\"javascript:doSomething('with a
parameter')\">link</a>";
</script>

Actual result:
--------------
<script type="text/javascript">
var link = "<a href=\?a=b"javascript:doSomething('with a
parameter')\">link</a>";
</script>

-- 
Edit bug report at https://bugs.php.net/bug.php?id=67887&edit=1
-- 



Thread (4 messages)

« previous php.bugs (#187239) next »