Uploaded image for project: 'GeoTools'
  1. GEOT-5703

Incorrect validation when parsing XML schema element declaration with ref attribute

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Lowest
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 16.3, 17.1, 18-beta
    • Component/s: xml
    • Labels:
      None

      Description

      Hi

      In a recent snapshot, there is a suspicious condition that may lead to a bug in modules/library/xml/src/main/java/org/geotools/xml/handlers/xsi/ElementTypeHandler.java

      292         if ((ref != null) || "".equalsIgnoreCase(ref)) {
      293             if (!(((name == null) || "".equalsIgnoreCase(name))
      294                     && ((type == null) || "".equalsIgnoreCase(type)))) {
      295                 throw new SAXException(
      296                     "Elements cannot have both a 'ref' and a 'name' + 'type' attribute");
      297             }
      298 
      299             name = type = ref;
      300         }
      

      In Line 292, when ref is null, the second condition will be always false. If ref will not be an empty string by a certain contract, this will not be an issue but just a code smell ("if (ref != null)" would be fine?). However, if Line 299 should not be executed when ref is an empty string, it should be (ref != null) && !"".equalsIgnoreCase(ref)? There would be other possible cases. This might be a trivial issue like minor code smell but wanted to report just in case. Thanks!

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                bencaradocdavies Ben Caradoc-Davies
                Reporter:
                lifove JC Nam
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: