[ 
https://issues.apache.org/jira/browse/ANY23-350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16525691#comment-16525691
 ] 

ASF GitHub Bot commented on ANY23-350:
--------------------------------------

GitHub user HansBrende opened a pull request:

    https://github.com/apache/any23/pull/87

    ANY23-350 fixed RDFParseException caused by malformed attributes

    The RDFParseException was caused by the following malformed markup:
    
    `<link rel=\"shortcut icon\">`
    
    Jsoup then cleaned this up into:
    
    `<link rel="\&quot;shortcut" icon\"="">`
    
    The problem with that was that the underlying SAX parser doesn't play well 
with attribute names that contain quotes, so the attribute name `icon\"` caused 
the following exception:
    
    ```
    org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 4536; Attribute 
name "icon" 
    associated with an element type "link" must be followed by the ' = ' 
character.
        at 
org.semarglproject.rdf4j.rdf.rdfa.RDF4JRDFaParser.parse(RDF4JRDFaParser.java:111)
        at 
org.semarglproject.rdf4j.rdf.rdfa.RDF4JRDFaParser.parse(RDF4JRDFaParser.java:95)
        at 
org.apache.any23.extractor.rdf.BaseRDFExtractor.run(BaseRDFExtractor.java:158)
    ```
    
    My solution to this problem was simply to sanitize all attribute names.
    
    mvn clean test -> all tests pass

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/HansBrende/any23 ANY23-350

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/any23/pull/87.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #87
    
----
commit c3abfe1c0cc51dbdd0404b313a2691ab62b33f78
Author: Hans <firedrake93@...>
Date:   2018-06-27T22:19:53Z

    ANY23-350 fixed RDFParseException caused by bad attribute names/values in 
malformed HTML

----


> RDFParseException: "icon" must be followed by ' = ' character
> -------------------------------------------------------------
>
>                 Key: ANY23-350
>                 URL: https://issues.apache.org/jira/browse/ANY23-350
>             Project: Apache Any23
>          Issue Type: Bug
>          Components: extractors
>    Affects Versions: 2.3
>            Reporter: Hans Brende
>            Priority: Minor
>
> I get the following error log when extracting from: 
> https://gunshowtrader.com/gunshows/arkansas/
> Haven't had time to debug this.
> {code}
> ERROR org.apache.any23.extractor.rdf.BaseRDFExtractor - Error while parsing 
> RDF document.
> org.eclipse.rdf4j.rio.RDFParseException: org.xml.sax.SAXParseException; 
> lineNumber: 1; columnNumber: 4536; Attribute name "icon" associated with an 
> element type "link" must be followed by the ' = ' character.
>       at 
> org.semarglproject.rdf4j.rdf.rdfa.RDF4JRDFaParser.parse(RDF4JRDFaParser.java:111)
>       at 
> org.semarglproject.rdf4j.rdf.rdfa.RDF4JRDFaParser.parse(RDF4JRDFaParser.java:95)
>       at 
> org.apache.any23.extractor.rdf.BaseRDFExtractor.run(BaseRDFExtractor.java:158)
>       at 
> org.apache.any23.extractor.rdf.BaseRDFExtractor.run(BaseRDFExtractor.java:57)
>       at 
> org.apache.any23.extractor.SingleDocumentExtraction.runExtractor(SingleDocumentExtraction.java:471)
>       at 
> org.apache.any23.extractor.SingleDocumentExtraction.run(SingleDocumentExtraction.java:259)
>       at org.apache.any23.Any23.extract(Any23.java:302)
>       at org.apache.any23.Any23.extract(Any23.java:437)
>       at 
> com.utownapp.crawl.tripledb.Triples.lambda$extractTriples$0(Triples.java:146)
>       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>       at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>       at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>       at java.lang.Thread.run(Thread.java:748)
> Caused by: org.semarglproject.rdf.ParseException: 
> org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 4536; Attribute 
> name "icon" associated with an element type "link" must be followed by the ' 
> = ' character.
>       at 
> org.semarglproject.rdf.rdfa.RdfaParser.processException(RdfaParser.java:1141)
>       at org.semarglproject.source.XmlSource.process(XmlSource.java:50)
>       at 
> org.semarglproject.source.StreamProcessor.processInternal(StreamProcessor.java:87)
>       at 
> org.semarglproject.source.BaseStreamProcessor.process(BaseStreamProcessor.java:167)
>       at 
> org.semarglproject.source.BaseStreamProcessor.process(BaseStreamProcessor.java:154)
>       at 
> org.semarglproject.rdf4j.rdf.rdfa.RDF4JRDFaParser.parse(RDF4JRDFaParser.java:109)
>       ... 12 more
> Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 4536; 
> Attribute name "icon" associated with an element type "link" must be followed 
> by the ' = ' character.
>       at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>       at org.semarglproject.source.XmlSource.process(XmlSource.java:48)
>       ... 16 more
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to