gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r10319: Improve prefix/namespace loo


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10319: Improve prefix/namespace lookup model, and make sure the container isn't
Date: Fri, 21 Nov 2008 18:03:24 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10319
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2008-11-21 18:03:24 +0100
message:
  Improve prefix/namespace lookup model, and make sure the container isn't
  destroyed before using its iterator.
modified:
  libcore/asobj/XMLNode_as.cpp
=== modified file 'libcore/asobj/XMLNode_as.cpp'
--- a/libcore/asobj/XMLNode_as.cpp      2008-11-21 10:50:16 +0000
+++ b/libcore/asobj/XMLNode_as.cpp      2008-11-21 17:03:24 +0000
@@ -290,10 +290,10 @@
 {
     XMLNode_as* node = this;
     PropertyList::SortedPropertyList::const_iterator it; 
+    PropertyList::SortedPropertyList attrs;
     
     while (node)
     {
-        PropertyList::SortedPropertyList attrs;
         enumerateAttributes(*node, attrs);
         if (!attrs.empty())
         {
@@ -309,13 +309,17 @@
 
     // Return the matching prefix
     const std::string& name = it->first;
-    std::string::size_type pos = name.find(':');
-
-    /// If we have a match and there is no colon, this is a standard
-    /// namespace.
-    if (pos == std::string::npos) return true;
+
+    if (name.length() == 5) {
+        return true;
+    }
+
+    assert (name.length() >= 6);
     
-    prefix = name.substr(pos + 1);
+    if (name[5] != ':') return false;
+
+    // Can also be empty.
+    prefix = name.substr(6);
     return true;
     
 }
@@ -325,10 +329,10 @@
 {
     XMLNode_as* node = this;
     PropertyList::SortedPropertyList::const_iterator it; 
+    PropertyList::SortedPropertyList attrs;
     
     while (node)
     {
-        PropertyList::SortedPropertyList attrs;
         enumerateAttributes(*node, attrs);
         if (!attrs.empty())
         {
@@ -956,7 +960,7 @@
         const std::string& ns)
 {
     StringNoCaseEqual noCaseCompare;
-    return (noCaseCompare(val.first.substr(0,5), "xmlns") && 
+    return (noCaseCompare(val.first.substr(0, 5), "xmlns") && 
                 noCaseCompare(val.second, ns));
 }
 
@@ -972,18 +976,12 @@
     // Attributes are stored with no trailing or leading whitespace,
     // so a simple comparison should do. TODO: what about "xmlns:"?
     if (prefix.empty()) {
-        return noCaseCompare(name, "xmlns");
+        return noCaseCompare(name, "xmlns") || noCaseCompare(name, "xmlns:");
     }
 
-    if (!noCaseCompare(name.substr(0, 5), "xmlns")) return false;
-
-    std::string::size_type pos = name.find(':');
-
-    // There is no colon or nothing after the colon, so this node has
-    // no matching prefix.
-    if (pos == std::string::npos) return false;
-
-    return noCaseCompare(prefix, name.substr(pos + 1));
+    if (!noCaseCompare(name.substr(0, 6), "xmlns:")) return false;
+
+    return noCaseCompare(prefix, name.substr(6));
 }
 
 } // anonymous namespace


reply via email to

[Prev in Thread] Current Thread [Next in Thread]