View Issue Details

IDProjectCategoryView StatusLast Update
0002154mantisbtbugtrackerpublic2014-10-02 18:21
Reporterrcarmo Assigned Tograngeway  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Summary0002154: HTML in news is rendered incorrectly
Description

If an A tag (link) is inserted in a news item, the source "<a... etc." is rendered, with an incorrect link highlight.

The string ends in ">;", which is wierd.

TagsNo tags attached.

Relationships

has duplicate 0002155 closedvboctor HTML in news is rendered incorrectly 

Activities

vboctor

vboctor

2002-06-25 02:40

manager   ~0002907

Using the latest CVS code I added a news item with a link to hotmail and it rendered fine. Is this what you are trying to do? Are you testing with the latest code or with 0.17.3?

bevindarkgun

bevindarkgun

2003-04-19 16:41

reporter   ~0004214

Last edited: 2003-04-19 16:46

I couldn't get exactly the same problem but I got something similar by entering the anchor tags myself rather than letting mantis just spot the uri.

The regexp's used in string_strip_hrefs() has a few problems:

  1. ...[^\"]>... should read ...[^>]>... so that attributes are matched
  2. .../s',... should read .../si',...so that upper case is matched
  3. the call to preg_replace() removes the tags but doesn't ensure that the whitespace etc. required by subsequent calls to string_insert_href() are present
The following example from the HTML 4.01 spec illustrates the linking problems:
<A href="http://www.w3.org/" charset="ISO-8859-1">W3C Web site</A> fails because of uppercase
<a href="http://www.w3.org/" charset="ISO-8859-1">W3C Web site</a> still fails because of the charset attribute
zzz<a href="http://www.w3.org/">W3C Web site</a>zzz fails due to non-whitespace
This one works:
<a href="http://www.w3.org/">W3C Web site</a>

I've put the following at the top of string_strip_hrefs() to fix 3:
# ensure any anchor tags are preceded by expected whitespace etc.
$p_string = preg_replace( '/(?<!^|<|[\s\:<\n\r])(<\/?a[^>]*>)/si',
' \1',
$p_string);

ensure any anchor tags are followed by expected whitespace etc.

$p_string = preg_replace( '/(<\/?a[^>]*>)(?!$|>|[\s\,>\n\r])/si',
'\1 ',
$p_string);

edited on: 04-19-03 16:46

jfitzell

jfitzell

2003-04-22 17:44

reporter   ~0004228

I've applied the first two fixes... I'm not happy with your solution for the third so I need to think about it and see if I can come up with a better one

msswift

msswift

2007-01-25 22:50

reporter   ~0013965

Last edited: 2007-01-26 10:23

The regexp in string_strip_hrefs has another problem:

it recognizes only double-quoted href attributes, whereas single-quoted attributes are also legal.

Here is a modified function, which is also more efficient (one call to preg_replace instead of two):


function string_strip_hrefs( $p_string ) {
$p_string = preg_replace( '/<a\s[^>]href=' .
'(?:' .
'"(?:mailto:)?([^\"]+)"' . # doublequoted, or
'|' .
"'(?:mailto:)?([^\']+)'" . # singlequoted
')' .
'[^>]
>[^\<]*<\/a>/si',

exactly one of sub-patterns 1 and 2 matched, so

                        # one is empty, the other is what we want
                        '\\1\\2',
                        $p_string);

return $p_string;
}

msswift

msswift

2007-01-26 10:43

reporter   ~0013967

Why does the function decline to match anchors with subtags?
For example:


<a href="mailto:john@example.com">my good friend</a>

I see no reason why it shouldn't, in which case replace the


[^<]

with

.
?

grangeway

grangeway

2014-09-22 15:40

reporter   ~0041276

I'm resolving this issue as "no change required" - please do not hesitate to reopen the issue if you believe that this issue should still be looked into.

We've been considering deprecating removing the news feature for a while.

In addition, the string_api regex code has been rewritten/tweaked multiple times since 2002 and the descriptions entered into this tracker have been rendered so it makes it hard to understand the raw data.

If there's still an issue here with the parsing can you:

1) Reopen and update this issue with a raw example that needs fixing
2) Email me directly at paul@mantisforge.org the same raw example that needs fixing (in case the parser being used on notes changes the text)
3) if you are on the mantisbt-dev/user mailing list, email that instead so everyone can have a look.

Thanks
Paul (paul@mantisforge.org)

Related Changesets

MantisBT: master c2d87939

2003-04-22 11:42

Julian Fitzell


Details Diff
Fix a few bugs pointed out in issue 0002154 by bevindarkgun <bevindarkgun@yahoo.com>

* core/string_api.php
(html_strip_hrefs):
+ fix both regexes to use [^\>]*> instead of [^\"]*
+ make regex searches case insensitive to we pick up anchors with
A as well as a, etc

git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@2157 <a class="text" href="/?p=mantisbt.git;a=object;h=f5dc347c">f5dc347c</a>-c33d-0410-90a0-b07cc1902cb9
Affected Issues
0002154
mod - core/string_api.php Diff File