Closed Bug 439548 Opened 16 years ago Closed 16 years ago

When tag name is substring of other tag, tag can not be added.

Categories

(MailNews Core :: Database, defect)

defect
Not set
major

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.9

People

(Reporter: World, Assigned: mnyromyr)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

Spin-off of Bug 433175 Commant #15 (trunk part).

With Name=Thunderbird,Version=3.0a2pre,BuildID=2008061203 on MS Win-XP SP2.

When tag name is substring of other tag, tag can not be added.
(1) Define tags named "abc", "ab", "bc".
(2) Copy two mails in a new folder.
(3-1) Mail-1: add tag, "ab", "bc", then "abc" => all tags are added.
(3-2) Mail-2: add tag of "abc".
      Once "abc" is added, unable to add "ab" or "bc". (Tb does do nothing) 
Problem of (3-2) doesn't occur with Tb 2.0.0.14. 

Note:
Although Tb trunk currently can not generate "X-Mozilla-Keys: abc ab bc" due to this bug, Bug 433175 (spin in Virtul Folder) probably occurs on Tb trunk too, if such tag combination was generated in Tb 2 era.
JFTR: This bug exists in current SeaMonkey trunk also.
Blocks: tb-tagsmeta
Attached patch fix MsgFindKeywords (obsolete) — Splinter Review
The problem is MsgFindKeywords in nsMsgUtils.cpp, which has two problems:
1. It encounters "ab" at position 0 in "abc", finds out it doesn't match and runs on - but it doesn't check if it's still inside the string and runs through memory until it finds somthing remotely matching.
2. But this is only a side effect of a string function mismatch: keywords.Find ends up in the obsolete "nsTString_CharT::Find( const nsCString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;" instead of the intended "nsAString::Find(const self_type& aStr, PRUint32 aOffset, ComparatorFunc c = DefaultComparator) const;", and so the parameters are met *wrongly*!

This patch takes some complexity out of the function and adds the required parameter, so that it works - but actually the function mismatch should be fixed, because we do want to use the frozen API!

David, ideas?
Assignee: bienvenu → mnyromyr
Status: NEW → ASSIGNED
Attachment #325452 - Flags: superreview?(bienvenu)
Attachment #325452 - Flags: review?(bienvenu)
Severity: normal → major
Karsten, thx for working on this - I was just starting to debug it. I'll test your fix. You're right that we should try to fix this using the frozen api but I don't know what that actually entails. I bet Neil knows though :-)
Comment on attachment 325452 [details] [diff] [review]
fix MsgFindKeywords

+  // 'keyword' is the single keyword to be sought
+  // 'keywords' is a space delimited list of keywords to be searched,
+  // which may be deteriorated to a single keyword or even be empty

instead of "to be sought", maybe "we're looking for"

instead of "deteriorated to a", how about "just".

This patch works a lot better than what was there before. I'm hitting this assertion:
          NS_ASSERTION(keywords.IsEmpty() || keywords.CharAt(0) != ' ', "space only keyword");

when I do a remove all keywords but it may be that an other bug messed up my keyword headers. I'll try to fix that other bug and see if I still see the assertion.
FYI. Bug 367011 exists in "0 Remove All Tags". 
FYI 2. Another one for "0 Remove All Tags" : Bug 368210.
Blocks: 439835
Blocks: 433175
(In reply to comment #2)
>but actually the function mismatch should be
>fixed, because we do want to use the frozen API!
Yeah, well blame bsmedberg for making the internal and external APIs different.
Comment on attachment 325452 [details] [diff] [review]
fix MsgFindKeywords

We should get this in.

Could you use #ifdef MOZILLA_INTERNAL_API ...#else ... to make this work when we switch to frozen linkages?
Attachment #325452 - Flags: superreview?(bienvenu)
Attachment #325452 - Flags: superreview+
Attachment #325452 - Flags: review?(bienvenu)
Attachment #325452 - Flags: review+
Will do, as soon as cvs.mozilla.org likes me again. :-(
Landed this on CVS trunk (1.9.0).
Attachment #325452 - Attachment is obsolete: true
Attachment #325791 - Flags: superreview+
Attachment #325791 - Flags: review+
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
VERIFIED with Name=Thunderbird,Version=3.0a2pre,BuildID=2008062003 on Win-XP SP2.

FYI.
All of "abc", "ab", "bc" is found by Virtual folder, and loop when "add tag, then define Virtual Folder" (Bug 439835) has disappeared.
But loop when "define Virtual Folder, then add tag" (Bug 433175) was still observed. (i.e. Now we can re-produce Bug 433175 with Tb Trunk.)
OS: Windows XP → All
Hardware: PC → All
Target Milestone: --- → mozilla1.9
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: