luehe       2002/09/05 12:05:23

  Modified:    jasper2/src/share/org/apache/jasper/compiler
                        ImplicitTagLibraryInfo.java
  Log:
  Fixed 12321: StackOverflow Exception when a tag defined by a tag file
               is called within a tag file
  
  Fix includes optimization so that only those tag files that are being
  referenced from the page (via custom actions) are parsed, instead of
  parsing any tag file located at the path specified by the 'tagdir'
  attribute of the taglib directive.
  
  Revision  Changes    Path
  1.8       +46 -10    
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java
  
  Index: ImplicitTagLibraryInfo.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ImplicitTagLibraryInfo.java       20 Aug 2002 15:50:22 -0000      1.7
  +++ ImplicitTagLibraryInfo.java       5 Sep 2002 19:05:23 -0000       1.8
  @@ -82,6 +82,12 @@
       private static final String TLIB_VERSION = "1.0";
       private static final String JSP_VERSION = "2.0";
   
  +    // Maps tag names to tag file paths
  +    private Hashtable tagFileMap;
  +
  +    private ParserController pc;
  +    private Vector vec;
  +
       /**
        * Constructor.
        */
  @@ -91,7 +97,10 @@
                                  String tagdir,
                                  ErrorDispatcher err) throws JasperException {
           super(prefix, tagdir);
  -     
  +     this.pc = pc;
  +     this.tagFileMap = new Hashtable();
  +     this.vec = new Vector();
  +
        tlibversion = TLIB_VERSION;
        jspversion = JSP_VERSION;
   
  @@ -110,9 +119,9 @@
            shortname = shortname.replace('/', '-');
        }
   
  +     // Populate mapping of tag names to tag file paths
        Set dirList = ctxt.getResourcePaths(tagdir);
        if (dirList != null) {
  -         Vector vec = new Vector();
            Iterator it = dirList.iterator();
            while (it.hasNext()) {
                String path = (String) it.next();
  @@ -123,16 +132,43 @@
                    String tagName = path.substring(path.lastIndexOf("/") + 1);
                    tagName = tagName.substring(0,
                                                tagName.lastIndexOf(TAG_FILE_SUFFIX));
  -                 TagInfo tagInfo = TagFileProcessor.parseTagFile(pc,
  -                                                                 tagName,
  -                                                                 path,
  -                                                                 this); 
  -                 vec.addElement(new TagFileInfo(tagName, path, tagInfo));
  +                 tagFileMap.put(tagName, path);
                }
            }
  +     }
  +    }
  +
  +    /**
  +     * Checks to see if the given tag name maps to a tag file path,
  +     * and if so, parses the corresponding tag file.
  +     *
  +     * @return The TagFileInfo corresponding to the given tag name, or null if
  +     * the given tag name is not implemented as a tag file
  +     */
  +    public TagFileInfo getTagFile(String shortName) {
  +
  +     TagFileInfo tagFile = super.getTagFile(shortName);
  +     if (tagFile == null) {
  +         String path = (String) tagFileMap.get(shortName);
  +         if (path == null) {
  +             return null;
  +         }
  +
  +         TagInfo tagInfo = null;
  +         try {
  +             tagInfo = TagFileProcessor.parseTagFile(pc, shortName, path,
  +                                                     this);
  +         } catch (JasperException je) {
  +             // XXX
  +         }
  +
  +         tagFile = new TagFileInfo(shortName, path, tagInfo);
  +         vec.addElement(tagFile);
   
            this.tagFiles = new TagFileInfo[vec.size()];
            vec.copyInto(this.tagFiles);
        }
  +
  +     return tagFile;
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to