~ubuntu-branches/ubuntu/natty/icedtea-web/natty-security

« back to all changes in this revision

Viewing changes to netx/net/sourceforge/jnlp/Parser.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2011-02-24 12:57:25 UTC
  • mto: (18.1.1 experimental) (19.1.1 natty-security)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: james.westby@ubuntu.com-20110224125725-8zq5v35r6o27w8ku
Tags: upstream-1.1~20110320
ImportĀ upstreamĀ versionĀ 1.1~20110320

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
    };
66
66
    */
67
67
 
68
 
    /** the supported JNLP file versions */
69
 
    private static Version supportedVersions = new Version("1.0 1.1 1.2 1.3 1.4 1.5 1.6 6.0");
70
 
 
71
68
    // fix: some descriptors need to use the jnlp file at a later
72
69
    // date and having file ref lets us pass it to their
73
70
    // constructors
128
125
        this.base = (codebase != null) ? codebase : base; // if codebase not specified use default codebase
129
126
        fileLocation = getURL(root, "href", this.base);
130
127
 
131
 
        // ensure version is supported
132
 
        if (!supportedVersions.matchesAny(spec))
133
 
            throw new ParseException(R("PSpecUnsupported", supportedVersions));
134
 
 
135
128
        // normalize the text nodes
136
129
        root.normalize();
137
130
    }
138
131
 
139
132
    /**
140
 
     * Return the JNLP specification versions supported.
141
 
     */
142
 
    public static Version getSupportedVersions() {
143
 
        return supportedVersions;
144
 
    }
145
 
 
146
 
    /**
147
133
     * Returns the file version.
148
134
     */
149
135
    public Version getFileVersion() {
350
336
        String part = getAttribute(node, "part", null);
351
337
        boolean main = "true".equals(getAttribute(node, "main", "false"));
352
338
        boolean lazy = "lazy".equals(getAttribute(node, "download", "eager"));
353
 
        int size = Integer.parseInt(getAttribute(node, "size", "0"));
354
339
 
355
340
        if (nativeJar && main)
356
341
            if (strict)
460
445
            String name = child.getNodeName();
461
446
 
462
447
            if ("title".equals(name))
463
 
                addInfo(info, child, null, getSpanText(child));
 
448
                addInfo(info, child, null, getSpanText(child, false));
464
449
            if ("vendor".equals(name))
465
 
                addInfo(info, child, null, getSpanText(child));
 
450
                addInfo(info, child, null, getSpanText(child, false));
466
451
            if ("description".equals(name)) {
467
452
                String kind = getAttribute(child, "kind", "default");
468
453
                if (descriptionsUsed.contains(kind))
470
455
                        throw new ParseException(R("PTwoDescriptions", kind));
471
456
 
472
457
                descriptionsUsed.add(kind);
473
 
                addInfo(info, child, kind, getSpanText(child));
 
458
                addInfo(info, child, kind, getSpanText(child, false));
474
459
            }
475
460
            if ("homepage".equals(name))
476
461
                addInfo(info, child, null, getRequiredURL(child, "href", base));
788
773
                if (title != null && strict) {
789
774
                    throw new ParseException(R("PTwoTitles"));
790
775
                }
791
 
                title = getSpanText(child);
 
776
                title = getSpanText(child, false);
792
777
            } else if ("description".equals(name)) {
793
778
                if (description != null && strict) {
794
779
                    throw new ParseException(R("PTwoDescriptions"));
795
780
                }
796
 
                description = getSpanText(child);
 
781
                description = getSpanText(child, false);
797
782
            } else if ("icon".equals(name)) {
798
783
                if (icon != null && strict) {
799
784
                    throw new ParseException(R("PTwoIcons"));
890
875
    }
891
876
 
892
877
    // XML junk
893
 
 
894
878
    /**
895
879
     * Returns the implied text under a node, for example "text" in
896
880
     * "<description>text</description>".
899
883
     * @throws ParseException if the JNLP file is invalid
900
884
     */
901
885
    public String getSpanText(Node node) throws ParseException {
 
886
        return getSpanText(node, true);
 
887
    }
 
888
 
 
889
    /**
 
890
     * Returns the implied text under a node, for example "text" in
 
891
     * "<description>text</description>". If preserveSpacing is false,
 
892
     * sequences of whitespace characters are turned into a single
 
893
     * space character.
 
894
     *
 
895
     * @param node the node with text under it
 
896
     * @param preserveSpacing if true, preserve whitespace
 
897
     * @throws ParseException if the JNLP file is invalid
 
898
     */
 
899
    public String getSpanText(Node node, boolean preserveSpacing)
 
900
            throws ParseException {
902
901
        if (node == null)
903
902
            return null;
904
903
 
905
904
        // NANO
906
 
        return node.getNodeValue();
 
905
        String val = node.getNodeValue();
 
906
        if (preserveSpacing) {
 
907
            return val;
 
908
        } else {
 
909
            if (val == null) {
 
910
                return null;
 
911
            } else {
 
912
                return val.replaceAll("\\s+", " ");
 
913
            }
 
914
        }
907
915
 
908
916
        /* TINY
909
917
        Node child = node.getFirstChild();