warning: simplexml_load_string() - magento-1.9

After I successfully installed the Theme in magento 1.9 there is an error in
system log warning: simplexml_load_string(): Entity: line 15: parser
error : Opening and ending tag mismatch in Update.php line 450

check the xml files in the theme, mostly there is a missing closing tags, check them using a good IDE & it will show what's missing.

Open up app/code/core/Mage/Core/Model/Layout/Update.php and go down to line 450 where the error is occurring. Right before that line, insert a new line:
Mage::log(print_r($filename, true));
Make sure your logging is turned on, then refresh the page in your browser. It will end up spitting out a bunch of layout files in your var/log/system.log. The last layout xml file on the list should be your culprit. In my case, there were 4 spaces in front of the xml declaration in the last file on the list. So, I removed the spaces, and everything worked fine.
Don’t forget to remove the line you put in Update.php when you are done!

It is due to some tag in layout (.xml) files of theme. You need to make sure that there should not a extra "<" or ">" in your files. sometimes when we write code
>
"extra > remain" in files.
Simplest way to find out cause is
Use
Mage::log(print_r($filename, true));
in
this file app/code/core/Mage/Core/Model/Layout/Update.php
OR replace this line
$fileXml = simplexml_load_string($fileStr, $elementClass);
With
try {
$fileXml = simplexml_load_string($fileStr, $elementClass);
}
catch(Exception $e){
Mage::log(print_r($filename,null,"myerrorlog.log"));
}
Then open the myerrolog.log and get the name of erroneous xml file.

Related

Vim modeline in a JSON file

I'm trying to add the following vim modeline to my global .tern-config file:
// vim: set ft=json:
{
plugins: {
...
However, the Tern server fails to start, giving the following error:
Failed to start server:
Bad JSON in /Users/XXXXX/.tern-config: Unexpected token / in JSON at position 0
I suspect the reason for this error is JSON's lack of support for comments. I should note that the same modeline in my .eslintrc file works.
How do I include a vim modeline in my .tern-config file?
If one puts an object like this
"_vim_": { "modeline": "/* vim: set ft=json noet ts=4 sw=4: */" }
as first or last entry into the top-level object list of a json file it will be used as modeline by vim (as long as the line appears close enough at the beginning or end of the file, where "close enough" means: within the number of lines that vim scans for modelines according to its 'modelines' option which defaults to 5).
Also, the object's name ("_vim_") should be carefully chosen, so that -- at best -- it is ignored by the software that uses the file as input, or -- at least -- can be ignored by the software's users (i. e., it doesn't cause any side effect that would be considered as unwanted behaviour).
You won't able to do this in the file itself. JSON does not support comments, and it's a very unforgiving syntax.
This may work in some JSON files, like .eslintrc, but in others, you will be out of luck. The stricter JSON parsers will not allow it, so it depends on which parser the tool you're using at the moment is built on.
Rather than guessing which parsers are forgiving and which aren't, you are probably better off telling Vim how to do this using an autocmd.
autocmd BufNewFile,BufRead *.tern-config set filetype=json

Why are uri chars (or at least spaces) being dropped on an html file upload?

I have a file upload form and would like to use the filename on the server, however I notice that when I upload it the spaces are dropped. On the client/browser I can do something like this in an event called after the input type='file' element has changed:
function process_svg (e) {
var files = e.target.files || e.originalEvent.dataTransfer.files;
console.log(files[0].filename);
And if I upload a file with the name 'some file - type.ext' 'some file - type.ext' will be printed in the console. On the server (running bottle) however if I run:
#route('/some_route')
def some_route():
print(request.files['form_name_attr'].filename)
I get 'somefile-type.ext.' I am guessing this has to do with uri escaping (or lack there of), but since you cannot change a file preupload how do you get around this and preserve it? Strangely I cannot find mention of this on google, in part I have had trouble thinking of appropriate search terms, but I'm also aware that this may not actually be native behaviour, but a bug elsewhere in my code.
I do not think that is the case as I've issued these console.log and print statements at the end (right before the upload) and beginning (right when the server starts processing the request) and do not believe I really have any code to touch it in between, however if that is the case please let me know as I could be looking in the wrong direction.
You want raw_filename, not filename.
(Note that it may contain unsafe characters.)
#route('/some_route', method='POST')
def some_route():
print(request.files['form_name_attr'].filename) # "cleaned" file name
print(request.files['form_name_attr'].raw_filename) # unmodified file name
Found this in the source code for FileUpload.filename:
Only ASCII letters, digits, dashes, underscores and dots are allowed
in the final filename. Accents are removed, if possible. Whitespace is
replaced by a single dash. Leading or tailing dots or dashes are
removed. The filename is limited to 255 characters.

How to set empty file description using AutoItWrapper?

When I add this wrapper directive it changes the description field of my executable. But when I leave it empty (or omit the directive) its value defaults to Aut2Exe.
#AutoIt3Wrapper_Res_Description=
How can I change this behavior? Is there a parameter for AutoIt3Wrapper.exe that leaves it empty? This is the compile command executed by SciTE:
"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /in "C:\...\myscript.au3" /console
Looking at the AutoIt3Wrapper source code, which is provided in the installation, the following line (line 2326 in my installation) reads:
If $INP_Description = "" Then $INP_Description = FileGetVersion($AutoItBin, "FileDescription")
I believe that to be the source of the Aut2Exe description.
How to force the description to be blank is a bit trickier. The quick and easy hack is to have a script that runs after compilation that removes the description, I usually have reshacker somewhere to hand for tasks like this.
Long term, I will put the issue to the developer, as it seems strange to set a description when the user has explicitly left it blank.

org.supercsv.exception.SuperCsvException: unexpected end of file while reading quoted column beginning on line

I'm reading csv files using superCSV reader and got the following exception. the file has 80000 lines. As I remove the end lines the exception still happens so there's some line in file that's causing this problem. how do I fix this?
org.supercsv.exception.SuperCsvException: unexpected end of file while reading quoted column beginning on line 80000 and ending on line 80000
context=null
at org.supercsv.io.Tokenizer.readColumns(Tokenizer.java:198)
at org.supercsv.io.AbstractCsvReader.readRow(AbstractCsvReader.java:179)
at org.supercsv.io.CsvListReader.read(CsvListReader.java:69)
at csv.filter.CSVFilter.filterFile(CSVFilter.java:400)
at csv.filter.CSVFilter.filter(CSVFilter.java:369)
at csv.filter.CSVFilter.main(CSVFilter.java:292)
ICsvListReader reader = null;
String[] line=null;
ListlineList=null;
try{
reader = new CsvListReader(new FileReader(inputFile), CsvPreference.STANDARD_PREFERENCE);
while((lineList=reader.read())!=null){
line=lineList.toArray(new String[lineList.size()]);
}
}catch(Exception exp){
exp.printStackTrace();
error=true;
}
The fact that the exception states it begins and ends on line 80000 should mean that there's an incorrect number of quotes on that line.
You should get the same error with the following CSV (but the exception will say line 1):
one,two,"three,four
Because the 3rd column is missing the trailing quote, so Super CSV will reach the end of the file and not know how to interpret the input.
FYI here is the relevant unit test for this scenario from the project source.
You can try removing lines to find the culprit, just remember that CSV can span multiple lines so make sure you remove whole records.
The line shown in the error message is not necessarily the one with the problem, since unbalanced quotechars throw off SuperCSV's line detection.
If possible, open the csv in a spreadsheet problem (for instance libreoffice calc) and search (as in CTRL-F search) for the quote char.
Calc will usually import the file well, even if there is a mismatch but you will see the quotechar somewhere if you search for it. Then check in the csv if it is properly escaped. If it is, make sure SuperCSV knows about it. If it isn't, complain to the producer of the csv.

How can I disable Vim's HTML error highlighting?

I use Vim to edit HTML with embedded macros, where the macros are bracketed with double angle brackets, e.g., "<>". Vim's standard HTML highlighting sees the second "<" and ">" as errors, and highlights them as such. How can I prevent this? I'd be happy to either teach $VIMHOME/syntax/html.vim that double-angle-brackets are OK, or to simply disable the error highlighting, but I'm not sure how to do either one. ("highlight clear htmlTagError" has no effect. In fact, "highlight clear" has no effect in an HTML buffer.)
If you want to introduce full syntax highlighting in your macros, it'll be easiest to start with a syntax file like htmldjango ($VIMRUNTIME/syntax/htmldjango.vim, which then uses html.vim and django.vim from the same directory); in it, there is special meaning in {{ ... }}, among other things. You want it just the same, but with << and >> being your delimiters.
To just highlight << ... >> specially, you'd need a syntax line like this:
syntax region mylangMacro start="<<" end=">>" containedin=ALLBUT,mylangMacro
And then you could highlight it with:
highlight default link mylangMacro Macro
This could either go in ~/.vim/after/syntax/html.vim or could be done in the style of htmldjango as a new syntax highlighter (this would be my preferred approach; you can then make HTML files use this new syntax file with an autocmd).
(You can also remove the error highlighting with syntax clear htmlTagError which would go in the same sort of position. But hopefully you'll think getting separate highlighting is better than just removing the error.)
Here are instructions to edit existing syntax highlighting in Vim:
http://vimdoc.sourceforge.net/htmldoc/syntax.html#mysyntaxfile-add
vim runtime paths for Unix/Linux:
$HOME/.vim,
$VIM/vimfiles,
$VIMRUNTIME,
$VIM/vimfiles/after,
$HOME/.vim/after
Create a directory in your vim runtime path called "after/syntax".
Commands for Unix/Linux:
mkdir ~/.vim/after
mkdir ~/.vim/after/syntax
Write a Vim script that contains the commands you want to use. For example, to change the colors for the C syntax: highlight cComment
ctermfg=Green guifg=Green
Write that file in the "after/syntax" directory. Use the name of the syntax, with ".vim" added. For our C syntax: :w
~/.vim/after/syntax/c.vim
That's it. The next time you edit a C file the Comment color will be
different. You don't even have to restart Vim.
If you have multiple files, you can use the filetype as the directory
name. All the "*.vim" files in this directory will be used, for
example: ~/.vim/after/syntax/c/one.vim ~/.vim/after/syntax/c/two.vim
Alternatively, you could take a much easier route and use syntax highlighting within the Nano command line editor, which you can define your own syntax very easily with regular expressions:
http://how-to.wikia.com/wiki/How_to_use_syntax_highlighting_with_the_GNU_nano_text_editor