Uploaded image for project: 'OpenOLAT'
  1. OpenOLAT
  2. OO-1031

Improve SimpleHtmlParser for some special cases

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 9.3.3
    • Fix Version/s: 9.4.0
    • Component/s: Framework
    • Labels:
      None

      Description

      1. DOCTYPE can also be lower case
      2. in HTML5 the MIME type of linked stylesheets is not mandatory any more

      diff -r 8d9b24c8bd51 src/main/java/org/olat/core/util/SimpleHtmlParser.java
      --- a/src/main/java/org/olat/core/util/SimpleHtmlParser.java	Fri Feb 28 16:00:47 2014 +0100
      +++ b/src/main/java/org/olat/core/util/SimpleHtmlParser.java	Thu Mar 20 17:05:06 2014 +0100
      @@ -134,6 +134,8 @@
       		
       		// check for doctype
       		int docTypePos = cont.indexOf("<!DOCTYPE");
      +		if (docTypePos == -1) docTypePos = cont.indexOf("<doctype");
      +		if (docTypePos == -1) docTypePos = cont.toLowerCase().indexOf("<doctype");
       		if (docTypePos != -1 ) {
       			int endOfhtmlDocTypePos = cont.indexOf(">", docTypePos);
       			htmlDocType = cont.substring(docTypePos, endOfhtmlDocTypePos+1);
      @@ -174,13 +176,11 @@
       			}
       		} else {
       			// no head tag found - use everything between HTML and BODY tag to support those crippled pages as well
      -			htmlHead = cont.substring((cont.indexOf(">", spos))+1, bodypos);
      +			htmlHead = cont.substring((cont.indexOf(">", spos))+1, bodypos).toLowerCase();
       		}
       		if (htmlHead != null) {
       			// Filter out base tag
       			int bsPos = htmlHead.indexOf("<base ");
      -			if (bsPos == -1) bsPos = htmlHead.indexOf("<BASE ");
      -			if (bsPos == -1) bsPos = htmlHead.toLowerCase().indexOf("<BASE ");
       			if (bsPos != -1) {
       				int bePos = htmlHead.indexOf('>', bsPos + 6);
       				if (bePos > -1) {
      @@ -193,7 +193,8 @@
       			// olat and firefox problem 
       			htmlHead = filterHeader(htmlHead);
       			// Filter out CSS definitions from HEAD
      -			if (htmlHead.indexOf("text/css") > 0) ownCss = true;
      +			if (htmlHead.indexOf("text/css") > 0) ownCss = true;	// required for HTML 4.01
      +			else if (htmlHead.indexOf("stylesheet") > 0) ownCss = true;	// "purely advisory" for HTML 5
       			// Filter out character set
       			charsetName = checkForCharset(htmlHead);
       		}
      

        Attachments

          Activity

            People

            Assignee:
            srosse Stéphane Rossé
            Reporter:
            stephan Stephan Clemenz
            Tester:
            Florian Gnägi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h