Coder Social home page Coder Social logo

Comments (4)

jmanico avatar jmanico commented on May 31, 2024

from owasp-java-encoder.

cnsgithub avatar cnsgithub commented on May 31, 2024

Hello and thanks for your honest answer. I fully understand your point of not adding support for edge cases and keeping it small and simple. I don't know why Google Earth decided to implement it this way...

As I already have a delegator class in place to avoid dependencies to org.owasp.encoder throughout my code I worked around this issue by just adding this one:

	/**
	 * This is a special case of XML encoding that replaces angle brackets with numeric character entities (< and >) instead of entity references (< and >).
	 * This prevents Google Earth from rendering inadvertent HTML.
	 * @see <a href="http://kml4earth.appspot.com/kmlErrata.html?#encoding">KML Reference Errata</a>
	 * @see <a href="https://github.com/OWASP/owasp-java-encoder/issues/20">OWASP Issue</a>
	 */
	public static String kmlEncode(String str) {
		return org.owasp.encoder.Encode.forXml(str).replace("&lt;", "&#60;").replace("&gt;", "&#62;");
	}

I know that strictly replacing all entity references by their numerical representations would be the better but more complex approach. For the moment it solves the problem and I didn't manage to break out and inject HTML. Do you think the workaround sufficiently prevents all cases? Let me see, maybe forking your repo should be preferred in the end...

Bye

from owasp-java-encoder.

jmanico avatar jmanico commented on May 31, 2024

from owasp-java-encoder.

cnsgithub avatar cnsgithub commented on May 31, 2024

I also integrated a specialized KMLEncoder in https://github.com/cnsgithub/owasp-java-encoder. We can safely close this issue.

from owasp-java-encoder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.